Re: in(NULL)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jose(at)sferacarta(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: in(NULL)
Date: 2002-05-23 14:21:29
Message-ID: 5312.1022163689@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

jose <jose(at)sferacarta(dot)com> writes:
> I think I found a bug using the IN operator.
> select * from t where b not in (11,22,NULL);

This is not a bug. The behavior of NOT IN with NULLs is not very
intuitive but it is correct according to the SQL standard. The result
can only be FALSE (when b is 11 or 22, IN is definitely TRUE, so NOT IN
is definitely FALSE) or NULL (for anything else, the result is UNKNOWN).
Either way, this query will select no rows.

> I tried the same quesry in mysql and it give me
> a different result. Who are right?

If mysql gets this wrong, then they are not implementing NULLs per SQL
spec.

regards, tom lane

In response to

  • in(NULL) at 2002-05-22 13:38:07 from jose

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-05-23 14:41:20 Bug #674: JDBC: DatabaseMetaData.getColumns() "feature"
Previous Message Joel Burton 2002-05-23 13:06:00 Re: in(NULL)