From J.Kraaijeveld@Askesis.nl Mon Dec 3 05:52:36 2007 Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 332802E00B3 for ; Mon, 3 Dec 2007 01:52:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 92516-09 for ; Mon, 3 Dec 2007 01:52:32 -0400 (AST) Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) by postgresql.org (Postfix) with ESMTP id 3BC902E00AB for ; Mon, 3 Dec 2007 01:52:31 -0400 (AST) thread-index: Acg1cLC0Cel/6a8sTO+xlKqJ00X0cw== X-PMWin-Version: 2.6.1, Antivirus-Engine: 2.50.6 Received: from [172.31.1.1] ([172.31.1.1]) by obelix.askesis.nl with Microsoft SMTPSVC(5.0.2195.6713); Mon, 3 Dec 2007 06:52:29 +0100 Subject: alias required by standard or PostgreSQL? From: "Joost Kraaijeveld" Content-Class: urn:content-classes:message To: Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Content-Type: text/plain; charset="iso-8859-1" Date: Mon, 03 Dec 2007 06:52:29 +0100 Message-ID: <1196661149.5542.33.camel@panoramix.askesis.nl> MIME-Version: 1.0 X-Mailer: Evolution 2.10.3 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Dec 2007 05:52:29.0649 (UTC) FILETIME=[B0A85410:01C83570] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.033 tagged_above=0 required=5 tests=AWL=0.032, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200712/2 X-Sequence-Number: 29694 Hi, If I run the query "select * from (select * from table_name)" PostgreSQL complains with ERROR: subquery in FROM must have an alias HINT: For example, FROM (SELECT ...) [AS] foo. Is the alias required by the ISO standard or is this a PostgreSQL requirement? TIA -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl From tgl@sss.pgh.pa.us Mon Dec 3 06:13:36 2007 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 72F1F2E0104 for ; Mon, 3 Dec 2007 02:13:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09942-03 for ; Mon, 3 Dec 2007 02:13:33 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id AEAC62E00F6 for ; Mon, 3 Dec 2007 02:13:33 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lB36DTIQ009789; Mon, 3 Dec 2007 01:13:29 -0500 (EST) To: "Joost Kraaijeveld" cc: pgsql-sql@postgresql.org Subject: Re: alias required by standard or PostgreSQL? In-reply-to: <1196661149.5542.33.camel@panoramix.askesis.nl> References: <1196661149.5542.33.camel@panoramix.askesis.nl> Comments: In-reply-to "Joost Kraaijeveld" message dated "Mon, 03 Dec 2007 06:52:29 +0100" Date: Mon, 03 Dec 2007 01:13:29 -0500 Message-ID: <9788.1196662409@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/3 X-Sequence-Number: 29695 "Joost Kraaijeveld" writes: > "select * from (select * from table_name)" > PostgreSQL complains with > ERROR: subquery in FROM must have an alias > HINT: For example, FROM (SELECT ...) [AS] foo. > Is the alias required by the ISO standard Yes. A FROM-clause entry is defined as ::=
[ [ AS ] [ ] ] | [ AS ] [ ] | ::=
Note that the brackets show that a (ie, an alias) is optional for a regular table, but not for a subquery. regards, tom lane