why is that when I use the <> in sql it is not getting the null value

Example I have the following records on column_name "color": blue, red, green, null... when I do a select query .. select * from table_name where color <> red... The sql should return all records except those that have color red, right? Why is it not showing those value that have null as color? Thank you!

Answers


In general, any comparison with NULL returns false. If you want to also get NULL rows, you'll have to explicitly ask for them:

color <> 'red' OR color IS NULL

Need Your Help

How do you write and test your regular expressions?

php regex testing wizard

Is their any wizards or tools to create and test regular expressions for PHP, because it is so difficult :( ?