Re: NULL in IN clause

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: NULL in IN clause
Date: 2005-10-19 21:11:30
Message-ID: 26534.1129756290@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

=?iso-8859-2?Q?Havasv=F6lgyi_Ott=F3?= <h(dot)otto(at)freemail(dot)hu> writes:
> I have just run this command on 8.0.4 :

> SELECT 'foo' WHERE 0 NOT IN (NULL, 1);

> And it resulted is zero rows.
> Without NULL it is OK.
> Is this a bug, or the standard has such a rule?

This is per spec.

The computation is effectively
NOT (0 = NULL OR 0 = 1)
NOT (NULL OR FALSE)
NOT NULL
NULL
ie, the result is UNKNOWN, which WHERE treats the same as FALSE.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bryce W Nesbitt 2005-10-20 01:01:17 casting character varying to integer - order by numeric sort
Previous Message Guy Rouillier 2005-10-19 21:07:23 Re: [pgsql-advocacy] Oracle buys Innobase