Re: SQL command join question
От | Stephan Szabo |
---|---|
Тема | Re: SQL command join question |
Дата | |
Msg-id | 20061129165123.D23412@megazone.bigpanda.com обсуждение исходный текст |
Ответ на | SQL command join question ("Ehab Galal" <ehabgalal123@hotmail.com>) |
Список | pgsql-sql |
On Wed, 29 Nov 2006, Ehab Galal wrote: > I have three tables t1(a, b, c, d), t2(a, b, c, k), and t3(c, e). I need to > outer join them as shown below, but only have all tuples from t1 as output. > But the following syntax does not allow me to do so. > > 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); I think you don't want to alias the output of the t1/t2 join to t if you're planning to continue referring to t1 in the rest of the query since I think the alias is going to hide the original t1 name. I'm not sure which outer join you were trying to use, but assuming left for now, I think something likeSELECT t1.* FROM t1 left outer join t2 on (t1.a=t2.a and t1.b=t2.b) left outer join t3 on(t1.c=t3.c); might work for you.
В списке pgsql-sql по дате отправления: