Re: [SQL] WHERE clause?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] WHERE clause?
Дата
Msg-id 25399.931960802@sss.pgh.pa.us
обсуждение исходный текст
Ответ на WHERE clause?  (Jim Rowan <jmr@computing.com>)
Список pgsql-sql
Jim Rowan <jmr@computing.com> writes:
>     WHERE (new.host != old.host) or 
>     (old.host IS NOT NULL and new.host IS NULL) or
>         (old.host IS NULL and new.host IS NOT NULL);

> Is this the best way to code the WHERE?  What I'm really after is "did the
> value change?".  I found that the tests to see if one-but-not-both of the
> values is NULL are required to identify times when the value changed to or
> from NULL.  

Yes, because any ordinary operator applied to NULL will produce NULL,
which WHERE interprets as FALSE.  The only operations that actually
work on nulls are IS NULL/IS NOT NULL.  In 6.5 you can use COALESCE
as a handy abbreviation for certain sorts of IS NOT NULL tests, but
offhand I don't see a good way to apply it here.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] SQL query to check size of database
Следующее
От: Jérome Knöbl
Дата:
Сообщение: Prolem wiht long query?