From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | David Johnston <polobo(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Visibility of table aliases in CTEs |
Date: | 2013-11-16 16:39:33 |
Message-ID: | 52879FC5.1020905@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 16/11/2013 15:48, David Johnston wrote:
> Raymond O'Donnell wrote
>> Hello all,
>>
>> In a WITH query, are table aliases within a CTE isolated from the rest
>> of the query? For example, if I do this -
>>
>> with my_cte as (
>> select * from my_table t
>> )
>> ....
>>
>> - can I re-use the alias "t" elsewhere in the same query?
>>
>> I had a dig through the appropriate section of the docs, but the answer
>> wasn't obvious to me there.
>
> This seems like one of those "just try it and see what happens" kind of
> question. But since I'm mobile and cannot run SQL I'll just say that such
> an alias is indeed hidden. No different than:
>
> Select * from (tbla as alpha natrual join tblb as beta) as ab natural join
> tbla as alpha
Thanks David - I did indeed try it, and it seemed to be the case, but as
I'm not any kind of expert I wanted to make sure that my empirical
results were correct. :-)
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie
From | Date | Subject | |
---|---|---|---|
Next Message | Luca Ferrari | 2013-11-17 08:56:58 | Re: PGSQL: listing db/role and user/role relationships |
Previous Message | David Johnston | 2013-11-16 15:48:35 | Re: Visibility of table aliases in CTEs |