Re: NULLs ;-)

From: Ragnar <gnari(at)hive(dot)is>
To: "John D(dot) Burger" <john(at)mitre(dot)org>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: NULLs ;-)
Date: 2006-11-28 15:44:09
Message-ID: 1164728649.27070.167.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On þri, 2006-11-28 at 09:42 -0500, John D. Burger wrote:
> Scott Ribe wrote:
>
> > where a <> b or (a is null and b is not null) or (a is not null and
> > b is null)
>
> In the absence of IS DISTINCT FROM, I think this has the same semantics:
>
> where coalesce(a, b) <> coalesce(b, a)

sorry, but no.

test=# create table logic (a int, b int);
CREATE TABLE
test=# insert into logic values (null,null);
INSERT 34495399 1
test=# insert into logic values (null,1);
INSERT 34495400 1
test=# insert into logic values (1,null);
INSERT 34495401 1
test=# insert into logic values (1,1);
INSERT 34495402 1
test=# select a,b,
coalesce(a, b) <> coalesce(b, a) as coal,
a IS DISTINCT FROM b as dist from logic;
a | b | coal | dist
---+---+------+------
| | | f
| 1 | f | t
1 | | f | t
1 | 1 | f | f
(4 rows)

test=#

gnari

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2006-11-28 15:51:27 Re: AIX and getaddrinfo
Previous Message Lars Heidieker 2006-11-28 15:34:26 Re: FK pointing to a VIEW