Update query by joining multiple tables.

From: "Moiz Kothari" <moizpostgres(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Update query by joining multiple tables.
Date: 2007-01-17 11:20:18
Message-ID: 82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Guys,

on page this

http://www.postgresql.org/docs/8.1/interactive/sql-update.html, it is not
specified if a join can be done between multiple tables to update a table, i
tried and it worked just fine for me. Something like this :

Infact update can work between multiple tables to... do something like :

UPDATE employees SET sales_count = a.sales_count FROM accounts as a
WHERE a.name = 'Acme Corporation'
AND employees.id = a.sales_person;

considering sales_count as a column in accounts table.

Regards,
Moiz

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Stępnicki 2007-01-17 12:52:25 Postgresql & Oracle Heteregenous services - strange behaviour
Previous Message Tom Lane 2007-01-16 17:13:28 Re: Removing CONTEXT message