pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Frans de Wet <Frans@Playful.com>
To: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Retrieving the record not matched with a join.
Date: Wed, 31 Mar 1999 15:06:00 -0600
Message-ID: <D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail> (raw)

Try:
 SELECT * FROM A
  WHERE NOT EXISTS(SELECT 1 FROM B WHERE A.BID = B.BID);
	-DEJ

> Hi,
> 
> I have two tables, A and B.  A contains records which 
> includes an ID or one
> of the records in table B.
> 
> A would typically contain the fields:
> 
> IDA
> IDB
> DATA1
> DATA2
> 
> and B:
> 
> IDB
> DATA3
> DATA4
> 
> I have several records in both but a few of the records in A 
> has a IDB field
> which does not point to a valid record in B (the record has 
> been deleted).
> 
> I know how to get all the records in A that have existing 
> records in B.
> SELECT * FROM A, B WHERE A.BID = B.BID.
> 
> Now my question ... How do I get the records in A that DO NOT 
> have existing
> records in B ???
> 
> Perplexed look and deep frown ;-)
> 
> Thanks in Advance
> Frans



view thread (2+ messages)

Message-ID: <D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail>
Permalink:  ../D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail/
Also on:    postgresql.org/message-id/D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail

 · 

reply

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: djackson@cpsgroup.com, Frans@Playful.com
  Subject: Re: [SQL] Retrieving the record not matched with a join.
  In-Reply-To: <D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail>
  References: <D05EF808F2DFD211AE4A00105AA1B5D2037F87@cpsmail>

* 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