Re: Correlated subquery/update

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Correlated subquery/update
Дата
Msg-id 15921.979314725@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Correlated subquery/update  ("Nick Fankhauser" <nickf@ontko.com>)
Список pgsql-general
"Nick Fankhauser" <nickf@ontko.com> writes:
> In essence, I want to match up the records where one.a=two.c and update
> one.b with the value in two.d . In Oracle, I would use this statement:
> update one set b = (select d from two where one.a = two.c);
> in psql, I get a syntax error when I do this.

play=> create table one (a int, b text);
CREATE
play=> create table two (c int, d text);
CREATE
play=> update one set b = (select d from two where one.a = two.c);
UPDATE 0

Looks OK to me (at least in 7.0.* and 7.1).  What release are you using?

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "Nick Fankhauser"
Дата:
Сообщение: Correlated subquery/update
Следующее
От: Peter Gubis
Дата:
Сообщение: postgres replication