Re: What is the syntax for UPDATE from one table to another?

From: Jeff <threshar(at)torgo(dot)978(dot)org>
To: pw <p(dot)willis(at)telus(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: What is the syntax for UPDATE from one table to another?
Date: 2004-03-12 18:19:35
Message-ID: D11EFA3F-7451-11D8-8474-000D9366F0C4@torgo.978.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)jefftrout(dot)com>
http://www.jefftrout.com/
http://www.stuarthamm.net/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2004-03-12 18:32:06 Re: What is the syntax for UPDATE from one table to another?
Previous Message pw 2004-03-12 17:40:13 What is the syntax for UPDATE from one table to another?