Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0I17m082799; Wed, 17 Jan 2001 20:07:48 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f0I17NJ22278; Wed, 17 Jan 2001 20:07:28 -0500 (EST) To: "Diehl, Jeffrey" cc: "'Ken Corey '" , "'pgsql-sql@postgresql.org '" , "'pgsql-general@postgresql.org '" Subject: Re: [SQL] RE: Help with query. (*) In-reply-to: References: Comments: In-reply-to "Diehl, Jeffrey" message dated "Wed, 17 Jan 2001 13:17:57 -0700" Date: Wed, 17 Jan 2001 20:07:23 -0500 Message-ID: <22275.979780043@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200101/799 X-Sequence-Number: 2998 "Diehl, Jeffrey" writes: > Well, actually, I want to eventually delete the records from A if there is > an entry in B. That's why I am trying to use such a screwed up query. ;^) If you don't mind being nonstandard, you could still do it in join style: DELETE FROM a WHERE a.x = b.x AND blah blah blah ... Under Postgres this will form a join between A and B same as if you'd said SELECT FROM a,b WHERE a.x = b.x etc, and then delete the rows of A that are matched in the join. If you want to be bog-SQL-standard then you have to use the WHERE EXISTS construct that Josh mentioned. Unfortunately, that's likely to be a good deal slower (for large tables) under current releases of Postgres. We have hopes of bringing the performance of the EXISTS variant up to something close to the explicit join, but it's a version or two away yet. regards, tom lane