Re: not null - trivial, unexpected behavior

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: <john(at)august(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: not null - trivial, unexpected behavior
Date: 2001-06-16 16:11:54
Message-ID: Pine.LNX.4.30.0106161807450.755-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-06-16 16:21:16 Re: not null - trivial, unexpected behavior
Previous Message Rene Pijlman 2001-06-16 15:28:06 Re: not null - trivial, unexpected behavior