As a corollary to three-valued logic expressed in the previous blog, NOT IN comparisons are a regular source of surprise.
Consider this comparison of one against various values:

SELECT 1 <> 2 AND 1 <> 3;
 ?column?
----------
 t
 
SELECT 1 <> 2 AND 1 <> 3 AND 1 <> NULL;
 ?column?
----------
 (null)

Continue Reading »