The syntax for filtering for NULL
(i.e. the absence of a value) in WHERE
blocks is slightly different than 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
filters all rows that the condition is FALSE
or UKNOWN
and keeps only rows that the condition is TRUE
.