UPDATE of several columns using SELECT statement

From: "adam(dot)slachta" <adam(dot)slachta(at)xitee(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: UPDATE of several columns using SELECT statement
Date: 2009-03-17 14:55:47
Message-ID: 91442895E1BB4BDDAB025D42B472BE1C@milano
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am facing the following problem, nothing tough, I guess (hope)..think it
should be some syntactical problem:

1. When trying to update two columns

UPDATE myFirstTable SET (fistCol, secCol) = ( SELECT anotherFistCol,
anotherSecondCol FROM mySecondTable )

I am getting: ERROR: syntax error at or near "select"

2. When changed to (only the parentheses are changed):

UPDATE myFirstTable SET (fistCol, secCol) = (( SELECT anotherFistCol,
anotherSecondCol FROM mySecondTable ))

I am getting: ERROR: number of columns does not match number of values

Does anybody know, what I am doing wrong? Thank you very much and wish you a
luxurious day

Adam

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-03-17 14:58:37 Re: COPY command question
Previous Message Ivano Luberti 2009-03-17 14:45:50 COPY command question