What is the difference between "column is not null" and "column !=''" and 'column<> ''' in mysql query ?
If "emp" is one of the column of the t开发者_StackOverflowable in MySQL Database, please let me know, the difference between below queries:
emp <> ''
and emp not null
I'm confused, please help me.
The comparison with ''
checks if the string is equal to the empty string, and can always be performed.
The IS NOT NULL
test is only meaningful if the database column is nullable. You would make it nullable on purpose, specifically to be able to tell the difference between "I know this value, and it happens to be a blank" and "this value is not applicable here, or I do not know it".
You might also want to check out what the MySql docs say regarding NULL
values.
emp <> ''
won't match a column that is null. For null tests, you have to use emp is not null
, because null doesn't match anything.
emp <> ''
tests if the value is different of the empty string whereas emp is not null
tests is your value is different of null. When comparing with null, you should always use is null
or is not null
精彩评论