Received: from as.tksoft.com (gyw.com [209.55.67.177] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id VAA93646 for ; Sun, 19 Dec 1999 21:21:49 -0500 (EST) (envelope-from tjk@tksoft.com) Received: (from tjk@tksoft.com) by uno.tksoft.com (8.8.8/8.8.8) id SAA26856; Sun, 19 Dec 1999 18:18:26 -0800 From: "tjk@tksoft.com" Message-Id: <199912200218.SAA26856@uno.tksoft.com> Subject: Re: [SQL] MINUS emulation? To: bbaldwin@indyme.com (Barry Baldwin) Date: Sun, 19 Dec 1999 18:18:25 -0800 (PST) Cc: pgsql-sql@postgreSQL.org In-Reply-To: <319A9588FB5ED2119FAC00A0C912E3292785C0@INDYMEEXCH> from "Barry Baldwin" at Dec 19, 99 05:47:06 pm Content-Type: text Barry, > I'm trying to do a query that returns all the records in one table unless > they exist in another table. This implies you need this: Select A.field_id, A.data, B.field_id, B.data from table_1 A, table_2 B where A.field_id not in (select A.field_id from table_1 A, table_2 B where A.field_id = B.field_id); Troy > > Hi all, > > I'm trying to do a query that returns all the records in one table unless > they exist in another table. > > For example the first query I tried was this; > > Select A.field_id, A.data, B.field_id, B.data > from table_1 A, table_2 B > where A.field_id <> B.field_id; > > This query resulted in no records being returned, I believe this is because > Table_2 is empty. > > I then tried : > > Select field_id, data > from table_1 > minus > Select field_id, data > from table_2; > > This didn't work because the Minus directive isn't recognized. > > Does anyone have a suggestion on how I might accomplish this? > > TIA, > > Barry > > > ************ > >