Re: in(NULL) - Mailing list pgsql-bugs

From Tom Lane
Subject Re: in(NULL)
Date
Msg-id 5312.1022163689@sss.pgh.pa.us
Whole thread Raw
In response to in(NULL)  (jose <jose@sferacarta.com>)
List pgsql-bugs
jose <jose@sferacarta.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

pgsql-bugs by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: in(NULL)
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #674: JDBC: DatabaseMetaData.getColumns() "feature"