Re: getting rid of "Adding missing FROM-clause entry...."

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
Cc: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>, pgsql-sql(at)postgresql(dot)org
Subject: Re: getting rid of "Adding missing FROM-clause entry...."
Date: 2003-04-17 16:02:12
Message-ID: 6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 17 Apr 2003 21:22:17 +0530, Rajesh Kumar Mallah
<mallah(at)trade-india(dot)com> wrote:
>BTW any idea why the query which i posted is not
>working? and issuing a NOTICE.

I guess, in

UPDATE t1
SET ...
FROM (SELECT ... FROM t2
WHERE t2.id = t1.id);

the subselect is not correlated because t1 and the subquery are on the
same level. So the subquery is treated like a standalone query and as
it does not have t1 in its FROM clause, t1 is added automatically.
Then the result of the subquery is joined to each row of t1 for the
update. This also explains why all rows were updated to the same
values.

Servus
Manfred

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-04-17 16:04:53 Re: analyse question..
Previous Message Rajesh Kumar Mallah 2003-04-17 15:52:17 Re: getting rid of "Adding missing FROM-clause entry...."