Filtering for NULL in queries
suggest changeThe syntax for filtering for NULL (that is, the absence of a value) in a WHERE clause is different from filtering for specific values.
SELECT * FROM Employees WHERE ManagerId IS NULL ;
SELECT * FROM Employees WHERE ManagerId IS NOT NULL ;
Note that because NULL is not equal to anything, not even to itself, using equality operators = NULL or <> NULL (or != NULL) will always yield the truth value of UNKNOWN which will be rejected by WHERE.
WHERE rejects rows whose condition is FALSE or UNKNOWN and keeps only rows whose condition is TRUE.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents