On Wed, Oct 19, 2005 at 11:04:36PM -0700, CSN wrote:
> So, does NULL != 'abc' always evaluate to false?
It never evaluates to false -- it evaluates to NULL.
http://www.postgresql.org/docs/8.0/interactive/functions-comparison.html
The ordinary comparison operators yield null (signifying "unknown")
when either input is null. Another way to do comparisons is with the
IS DISTINCT FROM construct:
expression IS DISTINCT FROM expression
For non-null inputs this is the same as the <> operator. However,
when both inputs are null it will return false, and when just one
input is null it will return true. Thus it effectively acts as
though null were a normal data value, rather than "unknown".
Examples:
test=> SELECT NULL = 'abc';
?column?
----------
(1 row)
test=> SELECT NULL <> 'abc';
?column?
----------
(1 row)
test=> SELECT NULL IS DISTINCT FROM 'abc';
?column?
----------
t
(1 row)
test=> SELECT NULL IS DISTINCT FROM NULL;
?column?
----------
f
(1 row)
--
Michael Fuhr