有两张表 A , B
A:
ID TYPE DETAIL
101 类型1 类型101详细
201 类型2 类型201详细
103 类型1 类型103详细
104 类型1 类型104详细
B:
ID_1 ID_2
101 201
102 202
103 203
...
想实现同时选出 B 中两个字段在 A 中对应的 detail 信息
select detail_1, detail_2 ... from ...
detail_1 detail_2
类型101详细 类型201详细
类型102详细 类型202详细
类型103详细 类型203详细
------解决方案--------------------
这种结构注定性能不会太高,这样吧:
select (select detail from a where b.id_1 = a.id) as detail_1,
(select detail from a where b.id_2 = a.id) as detail_2
from b
------解决方案--------------------
select a.detail as d1,b.detail as d2
from(
select b.rn,a.detail
from a
,(select b.* ,rownum rn from b) b
where a.id=b.id1
) a
,(
select b.rn,a.detail
from a
,(select b.* ,rownum rn from b) b
where a.id=b.id2
) b
where a.rn=b.rn