Re: What is the syntax for UPDATE from one table to another? - Mailing list pgsql-general

From Jeff
Subject Re: What is the syntax for UPDATE from one table to another?
Date
Msg-id D11EFA3F-7451-11D8-8474-000D9366F0C4@torgo.978.org
Whole thread Raw
In response to What is the syntax for UPDATE from one table to another?  (pw <p.willis@telus.net>)
List pgsql-general
On Mar 12, 2004, at 12:40 PM, pw wrote:

>
> Hello,
>
> What is the proper syntax for updating a column inone table from
> a column in another?
>
> I have tried this:
>
> UPDATE destination_table FROM source_table SET
> destination_table.column_one = source_table.column_b WHERE constraint;
>

update destination_table set column_a = (select column_b from
source_table where blah blah blah ) where blah blah blah

You can reference the values in destination_table inside the select.
--
Jeff Trout <jeff@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/


pgsql-general by date:

Previous
From: Reece Hart
Date:
Subject: Re: Question on Opteron performance
Next
From: Bruno Wolff III
Date:
Subject: Re: What is the syntax for UPDATE from one table to another?