From: Ken Kline <ken@oldbs.com>
To: Frank Joerdens <frank@joerdens.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Weird NOT IN effect with NULL values
Date: Thu, 01 Mar 2001 13:32:52 -0500
Message-ID: <3A9E95D4.77C1594@oldbs.com> (raw)
References: <20010301191654.A12406@rakete.joerdens.de>
this is kind of weird but it is how it works.
You cannot use equality for null...
Null does not equal Null
Null means no value, since it's not a value
it can't equal anything another no value.
SELECT name
FROM customer
WHERE customer_id NOT IN
(
SELECT customer_id
FROM salesorder
)
and customer_id is not null;
should work
Ken
Frank Joerdens wrote:
> When doing a subselect with NOT IN, as in
>
> SELECT name
> FROM customer
> WHERE customer_id NOT IN (
> SELECT customer_id
> FROM salesorder
> );
>
> (from Bruce Momjian's book)
>
> I get no rows if the result column returned by the subselect
> contains NULL values. It works as expected if I remove the NULL values
> from the result set. Is this behaviour correct and if so, why?
>
> I am using 7.1 beta 4.
>
> Regards, Frank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: ken@oldbs.com, frank@joerdens.de
Subject: Re: Weird NOT IN effect with NULL values
In-Reply-To: <3A9E95D4.77C1594@oldbs.com>
References: <20010301191654.A12406@rakete.joerdens.de> <3A9E95D4.77C1594@oldbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox