Peter Eisentraut <peter_e@gmx.net> writes:
> ISTM that correlation names aren't allowed after joined tables in the
> first place.
> <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>
> <joined table> ::=
> <cross join>
> | <qualified join>
> | <left paren> <joined table> <right paren>
Keep looking:
<derived table> ::= <table subquery>
<table subquery> ::= <subquery>
<subquery> ::= <left paren> <query expression> <right paren>
<query expression> ::= <non-join query expression> | <joined table>
So you can writeSELECT A.* FROM (A NATURAL JOIN B) J
but inSELECT A.* FROM A NATURAL JOIN B J
the J will be taken as an alias for B not for the join. If they allowed
an alias clause on an unparenthesized <joined table>, the grammar would
be ambiguous...
regards, tom lane