pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Diehl, Jeffrey <jdiehl@sandia.gov>
Cc: 'Ken Corey ' <ken@kencorey.com>
Cc: 'pgsql-sql@postgresql.org ' <pgsql-sql@postgresql.org>
Cc: 'pgsql-general@postgresql.org ' <pgsql-general@postgresql.org>
Subject: Re: [SQL] RE: Help with query. (*)
Date: Wed, 17 Jan 2001 20:07:23 -0500
Message-ID: <22275.979780043@sss.pgh.pa.us> (raw)
In-Reply-To: <B51F0C636E578A4E832D3958690CD73E0130BD9F@es04snlnt>
References: <B51F0C636E578A4E832D3958690CD73E0130BD9F@es04snlnt>

"Diehl, Jeffrey" <jdiehl@sandia.gov> 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



view thread (15+ messages)  latest in thread

Message-ID: <22275.979780043@sss.pgh.pa.us>
Permalink:  ../22275.979780043@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22275.979780043@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jdiehl@sandia.gov, ken@kencorey.com, pgsql-general@postgresql.org
  Subject: Re: [SQL] RE: Help with query. (*)
  In-Reply-To: <22275.979780043@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox