Re: UPDATE .. FROM

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: UPDATE .. FROM
Дата
Msg-id 12016.1204897661@sss.pgh.pa.us
обсуждение исходный текст
Ответ на UPDATE .. FROM  ("Markus Bertheau" <mbertheau.pg@googlemail.com>)
Список pgsql-sql
"Markus Bertheau" <mbertheau.pg@googlemail.com> writes:
> I'm kind of stuck as to why postgresql doesn't understand what I mean in the
> following queries:

> UPDATE tag_data td SET td.usage_counter = td.usage_counter + 1 FROM
> tag_list_tag_data ltd WHERE ltd.tag_id = td.id AND ltd.id =  102483;
> ERROR:  column "td" of relation "tag_data" does not exist

You aren't supposed to specify a table name (nor alias) for a target
variable in a SET clause.  It's useless (since you can't update more
than one table) and it's ambiguous because of the possibility of
composite fields.  What you want is something like

UPDATE tag_data td SET usage_counter = td.usage_counter + 1 FROM ...
        regards, tom lane


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

Предыдущее
От: "Yura Gal"
Дата:
Сообщение: Re: RETURN QUERY generates error
Следующее
От: "Jamie Tufnell"
Дата:
Сообщение: Re: Composite UNIQUE across two tables?