Re: What is wrong with this PostgreSQL UPDATE statement??

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: What is wrong with this PostgreSQL UPDATE statement??
Дата
Msg-id 23096.1219459810@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: What is wrong with this PostgreSQL UPDATE statement??  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-sql
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> On Fri, 22 Aug 2008, Steve Johnson wrote:
>> update certgroups
>> set termgroupname = tg.termgroupname
>> from certgroups c, termgroup tg
>> where (c.days >= tg.mindays) and (c.days <= tg.maxdays);

> In recent PostgreSQL versions I believe this is properly written:
> update certgroups c
> set termgroupname = tg.termgroupname
> from termgroup tg
> where (c.days >= tg.mindays) and (c.days <= tg.maxdays);

Yeah, in PG's eyes the former is creating a cartesian join between two
versions of certgroups.  I think MSSQL interprets the FROM reference as
being the same as the update target, but we don't.

> At least as of SQL2003, I think both of the above use extensions,

Correct, the standard disallows a FROM clause altogether; and I'm not
sure that they weren't right.  No matter which way you resolve the above
ambiguity, you've still got the problem that the update behavior is
ill-defined if a given target row joins to more than one set of rows
from the other table(s).
        regards, tom lane


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: What is wrong with this PostgreSQL UPDATE statement??
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: [ADMIN] Regarding access to a user