Re: Questions about Exists-Not exists clause - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: Questions about Exists-Not exists clause
Date
Msg-id 20030725142029.GA19721@wolff.to
Whole thread Raw
In response to Re: Questions about Exists-Not exists clause  (M Spreij <nemo@mechintosh.com>)
List pgsql-novice
On Thu, Jul 24, 2003 at 22:46:36 +0200,
  M Spreij <nemo@mechintosh.com> wrote:
> >
> >SELECT * FROM A WHERE NOT EXISTS (SELECT NULL FROM B WHERE
> >A.field3=B.field6);
>
> I did this recently, using
> SELECT * FROM A WHERE field3 NOT IN (SELECT field6 FROM B)
>
> Now if this is totally wrong tell me *gently*, it's the first
> question I felt I was up to to answer :-)

If field6 can have null values these two queries aren't equivalent.
If field6 has a null value than for the second query the where clause
will never be true. It will either be false or unknown so that no rows
will be selected.

pgsql-novice by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Get the last record alone from the select statement.
Next
From: Jay R
Date:
Subject: More than one installation on the same machine