Why will mySQL not return a row with a null value when selecting != to a string

mysql

Solution

In `ANSI` SQL, `NULL` is neither equal to nor unequal to any value, including itself.

NULL = 'foo'
NULL != 'foo'
NULL = NULL
NULL != NULL

all evaluate to `NULL`. To test for nullness you must use `is null` or `is not null` in your query.

Problem

I have a table with a nullable varchar column. When selecting rows and specifying that I want rows with a value not equal to a given string, it does NOT return the rows where the value is null. For example: ``` ## if `value` is null, that row is ignored SELECT * FROM test_table WHERE value != 'some string' ``` I'd like to understand why that's happening. Example: http://sqlfiddle.com/#!2/83f0d/1

Original source

Related problems