Re: FW: "=" operator vs. "IS"

Поиск
Список
Период
Сортировка
От Jeff Boes
Тема Re: FW: "=" operator vs. "IS"
Дата
Msg-id 41955aeb655d4b2976f0ae6878b95fa6@news.teranews.com
обсуждение исходный текст
Ответ на FW: "=" operator vs. "IS"  ("Dmitri Bichko" <dbichko@genpathpharma.com>)
Список pgsql-sql
> I'm just curious - why is it not possible to use the "=" operator to
> compare values with NULL? I suspect that the SQL standard specified it
> that way, but I can't see any ambiguity in an expression like "AND
> foo.bar = NULL". Is it because NULL does not "equal" any value, and the
> expression should be read as "foo.bar is unknown"? Or is there something
> else I'm missing?

As noted elsewhere, joining two tables on "a.foo = b.foo" where both foo 
values are NULL is not usually what you want.

But if you really, truly do want that, then you always have this:

coalesce(a.foo,0) = coalesce(b.foo,0)

or a similar construct, using something in place of zero that has the 
same base type as a.foo and b.foo, and which doesn't occur in either table.

(Why? Because you really don't want

a.foo = coalesce(b.foo,0)

or

b.foo = coalesce(a.foo,0)

to give you false positives.)

-- 
(Posted from an account used as a SPAM dump. If you really want to get
in touch with me, dump the 'jboes' and substitute 'mur'.)
________
Jeffery Boes <>< jboes@qtm.net


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

Предыдущее
От: "Duane"
Дата:
Сообщение: URGENT - Need the DATA TYPES comparison for PostgreSQL and ORACLE and SQL Server
Следующее
От: "Bob Hobart"
Дата:
Сообщение: How to make a portable application?