Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 5C8099FB1D8 for ; Wed, 17 Jan 2007 07:20:37 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 96721-01 for ; Wed, 17 Jan 2007 07:20:17 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by postgresql.org (Postfix) with ESMTP id 74D8E9FA468 for ; Wed, 17 Jan 2007 07:20:21 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so1916907ugf for ; Wed, 17 Jan 2007 03:20:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=kK2wX+/v0KXHX6Fw4Tl8Hfam6av5AK3RxKl1tdqJ4PCagDMmQZuln8OkL7ewwZtX+JiKj/M0jJoJFa89c67f5D/41qCwf3gcfDawmG97zWHUGDmBhIGyuyOZm/3rvdR+S3ramZdx5R3xJvq16wQ20ZcofW7B6wbsc0GOO4U1/U4= Received: by 10.66.216.20 with SMTP id o20mr9280206ugg.1169032818904; Wed, 17 Jan 2007 03:20:18 -0800 (PST) Received: by 10.67.26.17 with HTTP; Wed, 17 Jan 2007 03:20:18 -0800 (PST) Message-ID: <82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com> Date: Wed, 17 Jan 2007 16:50:18 +0530 From: "Moiz Kothari" To: pgsql-sql@postgresql.org Subject: Update query by joining multiple tables. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_103532_3679585.1169032818860" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/65 X-Sequence-Number: 27217 ------=_Part_103532_3679585.1169032818860 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_103532_3679585.1169032818860 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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


------=_Part_103532_3679585.1169032818860--