SQL query syntax question

Поиск
Список
Период
Сортировка
От Alexander Levsha
Тема SQL query syntax question
Дата
Msg-id CALVauw3b4XPEzO0+GB1yjmN3Lm_9d5W_C2gWGcYid65W32Oo7Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: SQL query syntax question
Список pgsql-sql
<div dir="ltr"><span style="font-size:12.8px">Hello all.</span><div style="font-size:12.8px">I'm currently developing
anSQL parser/analyzer for internal PostgreSQL tool we use at my workplace.</div><div
style="font-size:12.8px">Naturally,i use psql in conjunction with PostgreSQL documentation to develop and verify my
work.</div><divstyle="font-size:12.8px"><br /></div><div style="font-size:12.8px">Recently i've noticed the following
oddityin query syntax/execution:</div><div style="font-size:12.8px"><br /></div><div style="font-size:12.8px"><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word">select(select c1 from tt) from t1 tt; 
--ERROR:  relation "tt" does not exist
--LINE 1: select (select c1 from tt) from t1 tt;</pre><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word"><br/></pre><pre
style="white-space:pre-wrap;word-wrap:break-word"><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word">select(select tt.c1 ) from t1 tt; 
--c1
------
--(0 rows)</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word"><font face="arial, helvetica,
sans-serif"><br/></font></pre><font face="arial, helvetica, sans-serif">Why doesn't the first one work when the second
oneworks fine? In other words, why do subquery's traget list and range table list use different namespaces to resolve
tablereferences/aliases? 
Is this an unintended behaviour, implementation detail or is there an actual reason for this?

Thanks for your help.
Alexander Levsha</font></pre></div></div>

В списке pgsql-sql по дате отправления:

Предыдущее
От: Selina Tech
Дата:
Сообщение: Re: how plsql work on postgresql
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: SQL query syntax question