From: | Richard Broersma Jr <rabroersma(at)yahoo(dot)com> |
---|---|
To: | Ehab Galal <ehabgalal123(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SQL command join question |
Date: | 2006-11-30 00:57:18 |
Message-ID: | 458025.22989.qm@web31815.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> SELECT t1.*
> FROM (t1 outer join t2 on (t1.a=t2.a and t1.b=t2.b)) t outer join t3 on
^^
> (t1.c=t3.c);
^^ -- which one t or t1?
> I'm getting the following error message:
> ERROR: invalid reference to FROM-clause entry for table "t1"
> HINT: There is an entry for table "t1", but it cannot be referenced from
> this part of the query.
I am not use if I am about to give to the correct advice, but here is what stands out at me:
when you specify an outer join, I believe that you have to specify whether it is a
(left|right|full).
Also you are using a "t" to alias the (t1 .. t2 on (...)). First of all, I am not sure this is
good syntax, but if I am wrong I will have learned something new. That aside, if it is legal
syntax, I don't believe that you can refer to any of it's enternal tables any more. So (t1.c=...)
should really be (t.c=...).
this is what I expect would work:
select
*
from
t1
left outer join
t2
on
((t1.a,t1.b) = (t2.a,t2.b))
left outer join
t3
on
(t1.c = t3.c)
;
Regards,
Richard Broersma Jr.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-11-30 01:02:34 | Re: SQL command join question |
Previous Message | Stephan Szabo | 2006-11-30 00:57:01 | Re: SQL command join question |