Re: Delete from Join - Mailing list pgsql-general

From Gwyneth Morrison
Subject Re: Delete from Join
Date
Msg-id 486BD33B.5070304@toadware.ca
Whole thread Raw
In response to Delete from Join  (Gwyneth Morrison <postgres@toadware.ca>)
Responses Re: Delete from Join
Re: Delete from Join
List pgsql-general
<div class="moz-text-plain" wrap="true" graphical-quote="true"
 style="font-family: -moz-fixed; font-size: 12px;" lang="x-western">

--- On Wed, 7/2/08, Gwyneth Morrison <a class="moz-txt-link-rfc2396E"
 href="mailto:postgres@toadware.ca"><postgres@toadware.ca> wrote:



  > From: Gwyneth Morrison <a
 class="moz-txt-link-rfc2396E" href="mailto:postgres@toadware.ca"><postgres@toadware.ca>
> Subject: [GENERAL] Delete from Join
> To: <a
 class="moz-txt-link-abbreviated"
 href="mailto:pgsql-general@postgresql.org">pgsql-general@postgresql.org
> Date: Wednesday, July 2, 2008, 3:15 PM
> Hello,
>
> Is it possible to use a join keyword in a delete?
>
> For example:
>
>      DELETE FROM data_table1
>                 using data_table2 INNER JOIN
>                         data_table1  ON data_table1.fkey =
> data_table2.pkey;
>
>
> It is not directly mentioned in the delete syntax but the
> delete refers
> to the select clause where JOIN is valid.
>
> G
>



>i have a example

>delete from t1 a using t2 b where a.id = b.oid

>A standard way to do it is

>delete from t1 a where id in (select a.id from t1 a inner join t2 b on (a.id = b.oid))


 Thank you for your reply,

 You are absolutely correct, it IS the standard way.

What I am actually trying to do here is write a program to convert MS SQL to Postgres.
I have had quite a bit of success so far, but this is a sticking point.

Apparently using the JOIN keyword directly in a delete statement is valid in MS.
I am trying to determine if it is valid in postgres which I figure it is not but cannot
find it exactly in the documentation.

So I guess the real question is, can the JOIN keyword be used directly in a delete as above.

G


--
Sent via pgsql-general mailing list (<a class="moz-txt-link-abbreviated"
 href="mailto:pgsql-general@postgresql.org">pgsql-general@postgresql.org)
To make changes to your subscription:
<a class="moz-txt-link-freetext"
 href="http://www.postgresql.org/mailpref/pgsql-general">http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: "Matt Magoffin"
Date:
Subject: Re: Memory use in 8.3 plpgsql with heavy use of xpath()
Next
From: Kris Jurka
Date:
Subject: Re: Memory use in 8.3 plpgsql with heavy use of xpath()