UPDATE of several columns using SELECT statement

Поиск
Список
Период
Сортировка
От adam.slachta
Тема UPDATE of several columns using SELECT statement
Дата
Msg-id 91442895E1BB4BDDAB025D42B472BE1C@milano
обсуждение исходный текст
Ответы Re: UPDATE of several columns using SELECT statement  (Sam Mason <sam@samason.me.uk>)
Re: UPDATE of several columns using SELECT statement  (Richard Huxton <dev@archonet.com>)
Список 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 по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: COPY command question
Следующее
От: Ivano Luberti
Дата:
Сообщение: Re: COPY command question