Re: Need efficient way to do comparison with NULL as an option - Mailing list pgsql-general

From Tom Lane
Subject Re: Need efficient way to do comparison with NULL as an option
Date
Msg-id 27685.1199506781@sss.pgh.pa.us
Whole thread Raw
In response to Need efficient way to do comparison with NULL as an option  ("D. Dante Lorenso" <dante@lorenso.com>)
Responses Re: Need efficient way to do comparison with NULL as an option  ("D. Dante Lorenso" <dante@lorenso.com>)
Re: Need efficient way to do comparison with NULL as an option  ("D. Dante Lorenso" <dante@lorenso.com>)
List pgsql-general
"D. Dante Lorenso" <dante@lorenso.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

pgsql-general by date:

Previous
From: "D. Dante Lorenso"
Date:
Subject: Re: Need efficient way to do comparison with NULL as an option
Next
From: "D. Dante Lorenso"
Date:
Subject: Re: Need efficient way to do comparison with NULL as an option