Re: Binding of "AS" vis "JOIN" - Mailing list pgsql-general

From Tom Lane
Subject Re: Binding of "AS" vis "JOIN"
Date
Msg-id 15911.1107540903@sss.pgh.pa.us
Whole thread Raw
In response to Binding of "AS" vis "JOIN"  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-general
"Karl O. Pinc" <kop@meme.com> writes:
> I'm doing some complicated joining and am getting error
> messages about unknown relations and can't figure out
> what's up.  I'm wondering if "as" aliasing gives
> an alias to the product of a join, not just the
> one table that appears immediately in front of the
> "as".  ?

If you write

    ... FROM (a JOIN b) AS c

then (1) the alias c refers to the whole join result, not either a or b
and (2) you can't directly reference the table aliases a or b from
outside this JOIN clause: the alias c masks them.  This behavior is per
SQL spec.

> The other question that sprang to mind while working
> on this was whether there's performance (or any other)
> implications of using WHERE conditions instead of
> JOIN inside FROM.

See
http://www.postgresql.org/docs/8.0/static/explicit-joins.html
(adjust URL to match the major version you are running, as the answers
vary).

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: plpgsql function errors
Next
From: "Juan Casero (FL FLC)"
Date:
Subject: Re: plpgsql function errors