Received: from trillium.nmsu.edu (trillium.NMSU.Edu [128.123.5.15]) by hub.org (8.8.8/8.7.5) with ESMTP id SAA26427 for ; Fri, 12 Jun 1998 18:50:24 -0400 (EDT) Received: (from brook@localhost) by trillium.nmsu.edu (8.8.8/8.8.8) id QAA00571; Fri, 12 Jun 1998 16:50:14 -0600 (MDT) Date: Fri, 12 Jun 1998 16:50:14 -0600 (MDT) Message-Id: <199806122250.QAA00571@trillium.nmsu.edu> From: Brook Milligan To: djackson@cpsgroup.com CC: pgsql-sql@postgreSQL.org In-reply-to: (djackson@cpsgroup.com) Subject: Re: [SQL] finding rows in one table not in another References: > I need to find the set of rows in one table that are not in another > table. I used a query like the following: > > select distinct id from mytable1 where id not in (select > distinct id from mytable2); > try: SELECT mytable1.id FROM mytable1 WHERE NOT EXIST (SELECT mytable2.id FROM mytable2 WHERE mytable1.id = mytable2.id); Thanks. That works except it should be EXISTS (i.e., plural). Cheers, Brook