Re: Questions about Exists-Not exists clause

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: M Spreij <nemo(at)mechintosh(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Questions about Exists-Not exists clause
Date: 2003-07-25 14:20:29
Message-ID: 20030725142029.GA19721@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Jul 24, 2003 at 22:46:36 +0200,
M Spreij <nemo(at)mechintosh(dot)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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jay R 2003-07-26 06:42:02 More than one installation on the same machine
Previous Message Ron Johnson 2003-07-25 12:36:51 Re: Get the last record alone from the select statement.