Re: [Q] Table aliasing
От
David Johnston
Тема
Re: [Q] Table aliasing
Дата
Msg-id
1380892291029-5773364.post@n5.nabble.com
Ответ на
[Q] Table aliasing (Ladislav Lenart)
Список
Дерево обсуждения
[Q] Table aliasing Ladislav Lenart <lenartlad@volny.cz>
Re: [Q] Table aliasing David Johnston <polobo@yahoo.com>
Re: [Q] Table aliasing Ladislav Lenart <lenartlad@volny.cz>
Re: [Q] Table aliasing Adam Jelinek <ajelinek@gmail.com>
Ladislav Lenart wrote > * Should I alias one of the references to deal? > * The above query works the same both with and without an alias, so is it > simply > a matter of taste / good practice? > * Where can I find more info about this, i.e. when the alias is mandatory > and > when it is only a convenience? I've scanned through > > > http://www.postgresql.org/docs/9.1/static/queries-table-expressions.html > > but it only mentions that subselect in FROM must have an alias. I would > like to > know about IN (...) and EXISTS (...). Aliases are mandatory for self-joins. Basically two relations at the same query level cannot have the same name. With sub-selects the inner level shields the outer level from being visible so an alias is optional. I believe the case of a correlated sub-query requires the alias for the same reason - otherwise you end up with a always true where clause when joining the supposed two deal tables together. There is no right/best way but it is always more clear to rename such that you avoid repeating the same relation name in the query. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Q-Table-aliasing-tp5773355p5773364.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
В списке pgsql-general по дате отправления