I just covered how comparisons with NULLs return more NULLs, so how do you test for NULL? There are actually two clauses designed specifically to compare NULLs.
The first is the IS NULL comparison clause. It is a clause rather than an operator because I mentioned earlier that operators on NULLs return NULLs. Here is how it works:
SELECT NULL = NULL;
?column?
----------
(null)
SELECT NULL IS NULL;
?column?
----------
t
SELECT NULL IS NOT NULL;
?column?
----------
f
SELECT * FROM inctest;
x
--------
30
40
(null)
SELECT * FROM inctest WHERE x IS NULL;
x
--------
(null)
SELECT * FROM inctest WHERE x IS NOT NULL;
x
----
30
40
If you're new here, you may want to subscribe to our RSS feed or follow us on Twitter for product announcements, event information, and industry news.
Comparing NULLs (Part 6/11)






