Search Postgresql Archives

Re: NULL != text ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux