Oracle:在另一个子查询中使用一个子查询的结果

时间:2011-09-02 11:04:09

标签: oracle subquery

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) t1Joint2,
(select t1.c1,t3.c3 from table3 t3 where t1.c1 = t3.c3) t1Joint3,
;

以上查询在Oracle中不起作用 任何解决方法?

使用Oracle 11g。

2 个答案:

答案 0 :(得分:5)

为什么不把它写成:

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"

答案 1 :(得分:1)

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
;