Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.2/8.9.1) with ESMTP id QAA35728 for ; Wed, 31 Mar 1999 16:06:19 -0500 (EST) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id PAA20961; Wed, 31 Mar 1999 15:06:18 -0600 (CST) Received: from unknown(144.210.12.10) by gauntlet.bjke.com via smap (4.1) id xma020537; Wed, 31 Mar 99 15:05:32 -0600 Received: by cpsmail with Internet Mail Service (5.5.2448.0) id ; Wed, 31 Mar 1999 15:06:01 -0600 Message-ID: From: "Jackson, DeJuan" To: Frans de Wet , pgsql-sql@postgreSQL.org Subject: RE: [SQL] Retrieving the record not matched with a join. Date: Wed, 31 Mar 1999 15:06:00 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" 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