Re: UPDATE with value from another table

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: UPDATE with value from another table
Date: 2002-03-02 06:20:49
Message-ID: 1015050062.5762.873.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2002-03-02 at 05:08, Thomas T. Thai wrote:
> UPDATE [ ONLY ] table SET col = expression [, ...]
> [ FROM fromlist ]
> [ WHERE condition ]
>
> Is this valid:
>
> UPDATE table1
> SET col = table2.col
> FROM table2
> WHERE col = table2.id;

Yes, in principle:

junk=# UPDATE table1
junk-# SET col = table2.col
junk-# FROM table2
junk-# WHERE col = table2.id;
ERROR: Column reference "col" is ambiguous

WHERE table2.col = table1.id;

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"I will lift up mine eyes unto the hills, from whence
cometh my help. My help cometh from the LORD, which
made heaven and earth."
Psalms 121:1,2

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Reyes 2002-03-02 06:23:59 Re: Is vacuum full lock like old's vacuum's lock?
Previous Message Thomas T. Thai 2002-03-02 05:08:08 UPDATE with value from another table