Mested select into the from of a a Select structure

Started by Tourtounis Sotirisover 23 years ago2 messagesgeneral
Jump to latest
#1Tourtounis Sotiris
tourtoun@csd.uoc.gr

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)

#2Jakub Ouhrabka
jouh8664@ss1000.ms.mff.cuni.cz
In reply to: Tourtounis Sotiris (#1)
Re: Mested select into the from of a a Select structure

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:

Show quoted text

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