NULL: The Third Truth Value
Master the meaning of NULL, why NULL is not equal to anything (not even itself), and how three-valued logic affects WHERE clauses.
What Is NULL?
NULL represents unknown or missing data. It is not zero, not an empty string, not false. It is the explicit absence of a value.
NULL Is Not Equal to Anything (Not Even Itself)
This is the rule that trips everyone up:
SELECT NULL = NULL; -- NULL (not true!)
SELECT NULL = 0; -- NULL
SELECT NULL = ''; -- NULL
SELECT NULL <> 1; -- NULL