Re: Binding of "AS" vis "JOIN"

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Binding of "AS" vis "JOIN"
Дата
Msg-id 15911.1107540903@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Binding of "AS" vis "JOIN"  ("Karl O. Pinc" <kop@meme.com>)
Список 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 по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: plpgsql function errors
Следующее
От: "Juan Casero (FL FLC)"
Дата:
Сообщение: Re: plpgsql function errors