UPDATE of several columns using SELECT statement - Mailing list pgsql-general

From adam.slachta
Subject UPDATE of several columns using SELECT statement
Date
Msg-id 91442895E1BB4BDDAB025D42B472BE1C@milano
Whole thread Raw
Responses Re: UPDATE of several columns using SELECT statement
Re: UPDATE of several columns using SELECT statement
List 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

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: COPY command question
Next
From: Ivano Luberti
Date:
Subject: Re: COPY command question