pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Retrieving the record not matched with a join.
2+ messages / 2 participants
[nested] [flat]

* Retrieving the record not matched with a join.
@ 1999-03-31 20:53  Frans de Wet <Frans@Playful.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Frans de Wet @ 1999-03-31 20:53 UTC (permalink / raw)
  To: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* RE: [SQL] Retrieving the record not matched with a join.
@ 1999-03-31 21:06  Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jackson, DeJuan @ 1999-03-31 21:06 UTC (permalink / raw)
  To: Frans de Wet <Frans@Playful.com>; pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-03-31 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-31 20:53 Retrieving the record not matched with a join. Frans de Wet <Frans@Playful.com>
1999-03-31 21:06 RE: [SQL] Retrieving the record not matched with a join. Jackson, DeJuan <djackson@cpsgroup.com>

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