alias required by standard or PostgreSQL?

535 views
Skip to first unread message

Joost Kraaijeveld

unread,
Dec 3, 2007, 12:52:29 AM12/3/07
to
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


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Tom Lane

unread,
Dec 3, 2007, 1:13:29 AM12/3/07
to
"Joost Kraaijeveld" <J.Kraa...@Askesis.nl> 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

<table reference> ::=
<table name> [ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
| <derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <joined table>

<derived table> ::= <table subquery>

Note that the brackets show that a <correlation name> (ie, an alias)
is optional for a regular table, but not for a subquery.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply all
Reply to author
Forward
0 new messages