有两张表 A , BA:
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详细
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
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