Re: Need efficient way to do comparison with NULL as an option

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need efficient way to do comparison with NULL as an option
Date: 2008-01-05 04:19:41
Message-ID: 27685.1199506781@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"D. Dante Lorenso" <dante(at)lorenso(dot)com> writes:
> I'm looking for an operator that will compare NULL with NULL and
> evaluate as TRUE.

regression=# select null IS NOT DISTINCT FROM 42;
?column?
----------
f
(1 row)

regression=# select null IS NOT DISTINCT FROM null;
?column?
----------
t
(1 row)

However, if you're expecting this to be real efficient (like, use an
index), you're out of luck ...

> If the value I'm comparing is 0, I want it to match the NULL values.

[ raised eyebrow... ] Sir, you need to rethink your data
representation.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message D. Dante Lorenso 2008-01-05 04:57:48 Re: Need efficient way to do comparison with NULL as an option
Previous Message D. Dante Lorenso 2008-01-05 04:15:47 Re: Need efficient way to do comparison with NULL as an option