From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | Steve Johnson <stevej456(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: What is wrong with this PostgreSQL UPDATE statement?? |
Date: | 2008-08-23 02:50:10 |
Message-ID: | 23096.1219459810@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2008-08-25 17:08:14 | Re: Regarding access to a user |
Previous Message | Stephan Szabo | 2008-08-23 01:41:54 | Re: What is wrong with this PostgreSQL UPDATE statement?? |