X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 78B7830F536 for ; Tue, 1 Jul 2003 00:36:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 15924-06 for ; Mon, 30 Jun 2003 21:36:30 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by svr1.postgresql.org (Postfix) with ESMTP id A5A9930E89C for ; Mon, 30 Jun 2003 21:36:29 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3170217; Mon, 30 Jun 2003 17:36:40 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Robert Treat , pgsql-sql@postgresql.org Subject: Re: help with "delete joins" Date: Mon, 30 Jun 2003 17:35:29 -0700 User-Agent: KMail/1.4.3 References: <1057011998.24310.348.camel@camel> In-Reply-To: <1057011998.24310.348.camel@camel> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200306301735.29482.josh@agliodbs.com> X-Archive-Number: 200306/354 X-Sequence-Number: 14112 Robert, > delete * from foo where not (foo.a =3D bar.a and foo.b=3Dbar.b and > foo.c=3Dbar.c) ; >=20 > so i end up with=20 >=20 > postgres=3D# select * from foo;=20 > a | b | c | d=20 > ---+---+---+--- > 1 | 2 | 4 | A > 4 | 5 | 6 | b > (2 rows) >=20 > but thats not valid sql, is there some way to accomplish this?=20 Um, your example result doesn't match your pseudo-query. Assuming that you= =20 want to delete everything that DOES match, not everything that DOESN'T, do: DELETE FROM foo=20 WHERE EXISTS ( SELECT bar.a FROM bar WHERE bar.a =3D foo.a AND bar.b =3D foo.b AND bar.c =3D foo.c ); --=20 -Josh Berkus Aglio Database Solutions San Francisco