Re: not null - trivial, unexpected behavior - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: not null - trivial, unexpected behavior
Date
Msg-id Pine.LNX.4.30.0106161807450.755-100000@peter.localdomain
Whole thread Raw
In response to not null - trivial, unexpected behavior  (John Scott <jmscott@yahoo.com>)
Responses Re: not null - trivial, unexpected behavior
List pgsql-sql
John Scott writes:

> insert into A(a) values('a1');
> insert into A(a, b) values('a2', 'b2');
>
> select count(*) from A where b = null;      /* Returns 1, ok */

no

> select count(*) from A where b != null;     /* Returns 0 ... not ok! */

yes

> What am i missing?  Shouldn't those two sets be complimentary?

They should.  There's a thread about the abnormal behaviour of foo = NULL
in the -hackers archive of last/this(?) week.  You should use 'foo is
[not] null' anyway.

See also

http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/functions-comparison.html

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



pgsql-sql by date:

Previous
From: John Scott
Date:
Subject: not null - trivial, unexpected behavior
Next
From: Tom Lane
Date:
Subject: Re: not null - trivial, unexpected behavior