Update from select

From: Bret Stern <bret_stern(at)machinemanagement(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Update from select
Date: 2013-05-13 20:23:31
Message-ID: 1368476611.3693.16.camel@centos-dev.machinemanagement.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

PG 8.4

Having trouble putting together an update query to update
multiple columns in tbl1 from columns in tbl2.

update tbl1
set col3,col4,col5
from
(select col3, col4,col5 from tbl2 where col1="criteria")

Can someone add to the Postgres Docs (shown below) to help me with this.

UPDATE employees SET sales_count = sales_count + 1 WHERE id =
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation');

Many thanks

Bret Stern

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Tocci 2013-05-13 20:28:43 Re: Update from select
Previous Message Tom Lane 2013-05-13 18:39:17 Re: replanning Prepared Statements ?