Why does MySQL ignore null values when looking for not equal? -


I am not doing something strange in MySQL and I would like to see how it behaves like this and there Is there a way to change it?

Scenario

I have an Inodb table with the following column id, name, type , where type is empty - now , I can say that I have 10 records where they have type = "test" and 100 records with type IS NULL and 20 records where type = "standard"

if I I run this query

  from SELECT * accounts where the type & lt; & Gt; "Test"  

This query will only show me 20 records that have type = "standard" and it ignores 100 records which have zero values.

To work on this I have to do something like

  SELECT * accounts where IFNULL (type, "") & lt; & Gt; "Test"  

OR

  from the Select account where (type> "test" or type is IS NULL)  

Zero value means "aka no value" and it has no meaning & lt;> "test"

This is probably a required behavior, but I'm not sure Why is it designed

  select from accounts where type & lt; & Gt; This statement will mean 

"Select rows from accounts where the column type value is not equal to 'test'.

This means that mysql Pays those records which have a price which is not equal to "test"
Now here, because zero means that there is no value, it does not return those records, which type column There is no cost.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -