NULLs exist in a three-valued logic system, which frankly sounds scary. A
two-valued logic system, where things are either true or false, is very easy to understand. Three-valued logic sounds like something
is wrong, and in an sense something is wrong because it injects uncertainty (NULL) into a logic system which normally only
handles certainty. This is like the flat-nose pliers I mentioned
earlier — ideally we could do everything with two-valued
logic, but there are cases where three-valued logic, like pliers, is necessary, and we have to be able to deal with such cases:

SELECT NULL = 1;
 ?column?
----------
 (null)
 
SELECT NULL = '';
 ?column?
----------
 (null)
 
SELECT NULL = NULL;
 ?column?
----------
 (null)
 
SELECT NULL < NULL + 1;
 ?column?
----------
 (null)

Continue Reading »