Re: String Comparison and NULL

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: String Comparison and NULL
Дата
Msg-id 20080429124407.GA9643@tux
обсуждение исходный текст
Ответ на Re: String Comparison and NULL  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Ответы Re: String Comparison and NULL
Список pgsql-general
Pavel Stehule <pavel.stehule@gmail.com> schrieb:

> > ... and I do something like "select id where animal <> 'Cat';"  then
> > shouldn't 1, 3, 4 and 5 be picked?  As it is I only get 1, 4 and 5.
> > NULL is not 'Cat'.  I realize that if I were testing for NULL itself I

NULL is nothing, you can't compare something with nothing. As Pavel
suggested,


As Pavel suggested:

> In this case use operator IS DISTINCT FROM
>
> select id where animal IS DISTINCT FROM 'Cat';


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: varchar or text
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Sorting nulls and empty strings together