Received: from jupiter.hub.org (jupiter.hub.org [64.49.215.5]) by postgresql.org (Postfix) with ESMTP id 4CDB34768D4 for ; Wed, 6 Mar 2002 16:34:31 -0500 (EST) Received: (from news@localhost) by jupiter.hub.org (8.11.6/8.11.6) id g26LEB134826 for pgsql-sql@postgresql.org; Wed, 6 Mar 2002 15:14:11 -0600 (CST) (envelope-from news) From: "Llew" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: where not exists Date: Wed, 6 Mar 2002 21:14:11 -0000 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 31 Message-ID: References: Reply-To: "Llew" X-Complaints-To: news@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-sql@postgresql.org X-Archive-Number: 200203/139 X-Sequence-Number: 7019 Dear Josh, The reason why I do things is two steps is that this allows me archive the deleted items. Llew ""Josh Berkus"" wrote in message news:web-819049@davinci.ethosmedia.com... > Llew, > > Do it all in one query: > > > DELETE FROM a > > WHERE NOT EXISTS > > ( > > SELECT b.join1 > > FROM b > > WHERE > > a.join1 = b.join1 AND > > a.join2 = b.join2 > > ) > > And make sure that join1 and join2 are indexed in both tables. > > -Josh Berkus > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org