Re: Delete with a multi-column join?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: leon-pg(at)comvision(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Delete with a multi-column join?
Date: 2005-01-25 22:03:36
Message-ID: 20050125220336.GP29308@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 25, 2005 at 04:16:29PM -0500, leon-pg(at)comvision(dot)com wrote:
> Howdy! I apologize in advance for the ugly query I'm about to throw
> your way....
>
> I need to delete some data from a table based on a multi-column join.
> Is there a better way to write this?

Either:

delete
from tbldata
where (unitID,variableID,cycleID) in
(select unitID, variableID, cycleID from temp_data_table)

Or:

delete from tblData where
tblData.unitID = temp_data_table.unitID
and tblData.variableID = temp_data_table.variableID
and tblData.cycleID = temp_data_table.cycleID

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-01-25 22:15:01 Re: Size of data stored in bytea record?
Previous Message Magnus Hagander 2005-01-25 22:02:48 Re: EMBEDDED PostgreSQL