From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | CSN <cool_screen_name90001(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: NULL != text ? |
Date: | 2005-10-20 06:44:06 |
Message-ID: | 20051020064406.GA73462@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Roger Hand | 2005-10-20 06:45:10 | Re: PSQL suggested enhancement |
Previous Message | Michael Glaesemann | 2005-10-20 06:35:06 | Re: NULL != text ? |