Re: UPDATE .. JOIN?

From: Rodrigo E(dot) De León Plicet <rdeleonp(at)gmail(dot)com>
To: "Sergei Shelukhin" <realgeek(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: UPDATE .. JOIN?
Date: 2008-01-13 05:05:00
Message-ID: a55915760801122105n5c6faf40w5a15adad13d350b7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jan 12, 2008 11:26 PM, Sergei Shelukhin <realgeek(at)gmail(dot)com> wrote:
> Hmmm. What if there's more than one table? Is "from x,y" a viable option?

UPDATE table1 t1
SET blah = 1
FROM (
SELECT t2.t1id
FROM table2 t2
JOIN table3 t3
ON t2.id = t3.t2id
) foobar
WHERE t1.id = foobar.t1id

It's all in the docs:
http://www.postgresql.org/docs/8.2/static/sql-update.html

Good luck.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo E. De León Plicet 2008-01-13 05:10:15 Re: UPDATE .. JOIN?
Previous Message Gurjeet Singh 2008-01-13 04:44:42 ERROR during WAL replay