List:General Discussion« Previous MessageNext Message »
From:Corin Hartland-Swann Date:March 30 1999 2:45pm
Subject:x NOT IN (y) <=> x != y
View as plain text  
Hi there,

While trying to get my head around NULL values, I stumbled on the
following:

   CREATE TABLE foo (bar int);

   INSERT INTO foo VALUES (NULL),(1),(2);

   SELECT * FROM foo WHERE bar NOT IN (1);

returns NULL and 2

   SELECT * FROM foo WHERE bar != 1;

returns 2

NULL is supposed to mean "unknown value", so surely there is no way of
knowing whether the row where bar = NULL is 1 or not 1.

I'd always worked under the assumption that

   x NOT IN (y)        <=>       x != y

Can anyone explain this?

Thanks in advance,

Corin

/---------------------------------------------\
|                                             |
|      Corin Hartland-Swann - Webmaster       |
|                                             |
+---------------------------------------------+
|                                             |
|      The International Lyrics Network       |
|                                             |
|           http://www.lyrics.net/            |
|                                             |
| mysql 3.22.20 - apache 1.3.4 - perl 5.00505 |
|                                             |
\---------------------------------------------/


Thread
x NOT IN (y) <=> x != yCorin Hartland-Swann30 Mar
  • x NOT IN (y) <=> x != yMichael Widenius30 Mar
  • Re: x NOT IN (y) <=> x != yMartin B. Jespersen30 Mar
Re: x NOT IN (y) <=> x != yDerick H Siddoway31 Mar
Re: x NOT IN (y) <=> x != yMichael Widenius31 Mar