Re: Weird NOT IN effect with NULL values

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Frank Joerdens <frank(at)joerdens(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Weird NOT IN effect with NULL values
Date: 2001-03-01 18:42:10
Message-ID: 200103011842.NAA10441@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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.

Read more in the book. It covers subqueries with nulls, bottom of pages
96. Not sure about web URL but it is in the subqueries section titled
"NOT IN and Subqueries with NULL Values".

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-03-01 18:56:06 Re: Weird NOT IN effect with NULL values
Previous Message Ken Kline 2001-03-01 18:32:52 Re: Weird NOT IN effect with NULL values