[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] UPDATE table SET col = (SELECT ...)
From:       Ian Barwick <barwick () gmx ! net>
Date:       2003-06-26 21:11:10
[Download RAW message or body]

On Wednesday 25 June 2003 11:00, Vangelis-Maria Tougia wrote:
> Hi,
> I found follwing email sent to you in internet.
> I am interested in same issue myself.
> Did you finally found out any more information about how to Update a column
> of a table by selecting value from another table?

Not sure if this has been answered previously, but here goes:

> Hello,
>
> If I understand the SQL references I have read, UPDATEs are allowed to
> pull data from SELECT statements, something like
>
>   UPDATE table SET col1 = (SELECT val1 FROM table WHERE id = 34),
>                SET col2 = (SELECT val2 FROM table WHERE id = 34)
                 ^^^
>          WHERE id = 35;

The second "SET" is not necessary or allowed and is causing the update to
fail.


Ian Barwick
barwick@gmx.net



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic