Re: NULL != text ?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: NULL != text ?
Дата
Msg-id 20051020064406.GA73462@winnie.fuhr.org
обсуждение исходный текст
Ответ на NULL != text ?  (CSN <cool_screen_name90001@yahoo.com>)
Ответы Re: NULL != text ?  (Michael Glaesemann <grzm@myrealbox.com>)
Re: NULL != text ?  (CSN <cool_screen_name90001@yahoo.com>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: NULL != text ?
Следующее
От: "Roger Hand"
Дата:
Сообщение: Re: PSQL suggested enhancement