X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2BE1D1B211 for ; Tue, 29 Jun 2004 14:28:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07676-06 for ; Tue, 29 Jun 2004 17:28:51 +0000 (GMT) Received: from dyatel.antar.bryansk.ru (unknown [195.239.214.85]) by svr1.postgresql.org (Postfix) with ESMTP id 35FAFD1B198 for ; Tue, 29 Jun 2004 14:28:49 -0300 (ADT) Received: from fduch by dyatel.antar.bryansk.ru with local (Exim 4.34 (FreeBSD)) id 1BfMPZ-000K58-8o; Tue, 29 Jun 2004 21:28:49 +0400 Date: Tue, 29 Jun 2004 21:28:49 +0400 From: "Alexander M. Pravking" To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: UPDATE ... WHERE (subselect on the same table) Message-ID: <20040629172849.GB73173@dyatel.antar.bryansk.ru> References: <20040629161742.GA73173@dyatel.antar.bryansk.ru> <1981.1088527795@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <1981.1088527795@sss.pgh.pa.us> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/295 X-Sequence-Number: 18240 On Tue, Jun 29, 2004 at 12:49:55PM -0400, Tom Lane wrote: > > So I have two questions: > > Q1, cognitive. Why the alias for the updated table is restricted? > > Because the SQL standard doesn't allow an alias there. We've talked > about allowing one anyway, but no one's gotten around to it. AFAICS > it would only be a marginal notational advantage, not allow you to > express queries you can't express today. > > > Q2, vital. Can I be sure that the syntax I used here will work > > correctly, i.e. will the "test.name" always refer the column in outer > > table, not inner (t2)? > > Yes. The alias *completely* hides the real name of that table > reference, so "test" will never refer to "test t2". As always, perfectly clear, thank you Tom :) I already found in docs on SELECT: When an alias is provided, it completely hides the actual name of the table or table function; /me should RTFM... (repeating hundred times) -- Fduch M. Pravking