From: Sergey Konoplev <sergey.konoplev@postgresql-consulting.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: DELETE using an outer join
Date: Fri, 20 Jul 2012 18:13:31 +0400
Message-ID: <CAL_0b1uDMQuYqpwTEr6JCd5AiwzevCEGJsGiM2DiMoJr_-p=sA@mail.gmail.com> (raw)
In-Reply-To: <16160.1342792275@sss.pgh.pa.us>
References: <ju8veb$dkn$1@dough.gmane.org>
<21289.1342709554@sss.pgh.pa.us>
<CAL_0b1shAZWP76=jpA47MLJE4p3q9_FHnAAy9ki_gXk1kVYJuQ@mail.gmail.com>
<16160.1342792275@sss.pgh.pa.us>
On Fri, Jul 20, 2012 at 5:51 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> DELETE FROM some_table USING some_table AS s
>> WHERE
>> some_table.col1 = s.col1 AND
>> some_table.col2 = s.col2 AND
>> some_table.id < s.id;
>
> No, that's a self-join, which isn't what the OP wanted. You can make it
> work if you self-join on the primary key and then left join to the other
> table, but that's pretty klugy and inefficient.
>
> What was being discussed is allowing people to write directly
>
> DELETE FROM some_table USING some_table LEFT JOIN other_table ...
>
> where the respecification of the table in USING would be understood
> to mean the target table. Right now this is an error case because
> of duplicate table aliases.
Yes, the OP has already pointed me to it. Thank you for your explanation.
--
Sergey Konoplev
a database architect, software developer at PostgreSQL-Consulting.com
http://www.postgresql-consulting.com
Jabber: gray.ru@gmail.com Skype: gray-hemp Phone: +79160686204
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: sergey.konoplev@postgresql-consulting.com, tgl@sss.pgh.pa.us, spam_eater@gmx.net
Subject: Re: DELETE using an outer join
In-Reply-To: <CAL_0b1uDMQuYqpwTEr6JCd5AiwzevCEGJsGiM2DiMoJr_-p=sA@mail.gmail.com>
* 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