Thread: Mested select into the from of a a Select structure

Mested select into the from of a a Select structure

From
Tourtounis Sotiris
Date:
Performing an SQL query of the below general form to a table T

Table T :

col1 | col2 | col3
------------------
text | text | text

and the query is ...

select *
from (select Y.col1 from ....) Z, T
where  T.col2 = Z

I think this query should work - however it throws me an error to the
where clause, where it says that it doesn't find Z (ERROR:  Attribute 'z'
not found) - can anyone notice any mistake or overlap that i have made - i
would really appreciate any kind of help or advice - thank you a priori
!!!



                                                 SWTHRHS TOYRTOYNHS
                                                (tourtoun@csd.uch.gr)




Re: Mested select into the from of a a Select structure

From
Jakub Ouhrabka
Date:
hi,

try:

select *
from (select Y.col1 AS X from ....) Z, T
where  T.col2 = Z.X

'Z' is a table alias in your case, not column alias...

kuba

On Sat, 9 Nov 2002, Tourtounis Sotiris wrote:

>
> Performing an SQL query of the below general form to a table T
>
> Table T :
>
> col1 | col2 | col3
> ------------------
> text | text | text
>
> and the query is ...
>
> select *
> from (select Y.col1 from ....) Z, T
> where  T.col2 = Z
>
> I think this query should work - however it throws me an error to the
> where clause, where it says that it doesn't find Z (ERROR:  Attribute 'z'
> not found) - can anyone notice any mistake or overlap that i have made - i
> would really appreciate any kind of help or advice - thank you a priori
> !!!
>
>
>
>                                                  SWTHRHS TOYRTOYNHS
>                                                 (tourtoun@csd.uch.gr)
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>