Re: finding records not listed in a column, Postgresql

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Aaron Payne <apayneinc(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: finding records not listed in a column, Postgresql
Date: 2003-04-27 15:36:18
Message-ID: 20030427153618.GA26384@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sun, Apr 27, 2003 at 08:02:16 -0700,
Aaron Payne <apayneinc(at)yahoo(dot)com> wrote:
> Hi,
>
> I need the records in table A in which the values in
> A.objectID are not listed in B.objectID. I'm such a
> noob that I'm not sure of the terms I need to use for
> this statement.
>
> table A
> rows: person_id, objectID
>
> table B
> rows: id, objectID

Below are two ways of doing this. If A.objectID and B.objectID can both
be NULL, the records in A with NULL values won't be excluded.

select * from A
where not exists (select 1 from B where A.objectID = B.objectID);

select A.person_id, A.objectID from A right join B using (objectID)
where B.objectID is null;

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-04-27 15:51:04 Re: finding records not listed in a column, Postgresql
Previous Message Paul Makepeace 2003-04-27 15:28:19 Re: finding records not listed in a column, Postgresql