pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Manfred Koizar <mkoi-pg@aon.at>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: getting rid of "Adding missing FROM-clause entry...."
Date: Thu, 17 Apr 2003 18:02:12 +0200
Message-ID: <6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com> (raw)
In-Reply-To: <200304172122.17761.mallah@trade-india.com>
References: <3E9EB59F.B01FBF60@rodos.fzk.de>
	<200304172021.28073.mallah@trade-india.com>
	<dbht9vctbp8p6cmt5jt8rvaqb8tf34p2ci@4ax.com>
	<200304172122.17761.mallah@trade-india.com>

On Thu, 17 Apr 2003 21:22:17 +0530, Rajesh Kumar Mallah
<mallah@trade-india.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




view thread (10+ messages)  latest in thread

Message-ID: <6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com>
Permalink:  ../6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com/
Also on:    postgresql.org/message-id/6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mkoi-pg@aon.at, mallah@trade-india.com, ch@rodos.fzk.de
  Subject: Re: getting rid of "Adding missing FROM-clause entry...."
  In-Reply-To: <6ijt9vgiapkddv4o7cvj9rjprbmdkkcd8b@4ax.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox