开发者

Oracle: Using results of one subquery inside another

select t1Joint2.c1,t1Joint3.c3 from
(select * from table1 where name  = "some") t1,
(select t1.c1,t2.c2 from table2 t2 where t1.c1 = t2.c2) t1开发者_开发百科Joint2,
(select t1.c1,t3.c3 from table3 t3 where t1.c1 = t3.c3) t1Joint3,
;

The above query doesn't work in Oracle.

Any workaround?

Using Oracle 11g.


Why not write it as:

select t1.c1, t3.c3
from table1 t1
join table2 t2 on t1.c1 = t2.c2
join table3 t3 on t1.c1 = t3.c3
where name = "some"


with t1 as 
  (select * from table1 where name  = 'some')
, t1Joint2 as
  (select t1.c1,t2.c2 from t1,  table2 t2 where t1.c1 = t2.c2)
, t1Joint3 as
  (select t1.c1, t3.c3 from t1, table3 t3 where t1.c1 = t3.c3) 
select t1Joint2.c1,t1Joint3.c3 
from t1Joint2, t1Joint3
;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜