Ошибка «invalid reference to FROM-clause entry for table»
Имеется простейший код:
SELECT t.id FROM t AS u;
Получаю ошибку «invalid reference to FROM-clause entry for table "t"». В чём дело?
Ответы (1 шт):
Автор решения: Ainar-G
→ Ссылка
При использовании синонимов (англ. «alias»), в запросе нужно использовать только их. Из документации (выделение добавлено):
A substitute name for theFROMitem containing the alias. An alias is used for brevity or to eliminate ambiguity for self-joins (where the same table is scanned multiple times). When an alias is provided, it completely hides the actual name of the table or function; for example givenFROM foo AS f, the remainder of theSELECTmust refer to thisFROMitem asfnotfoo. If an alias is written, a column alias list can also be written to provide substitute names for one or more columns of the table.