日期:2014-05-17 浏览次数:20972 次
--b为从表一 c为从表2 select b.id,nvl(name1,null),nvl(name2,null) from b,c where b.id=c.id(+) ID N NVL( ----- - ---- 1 a 张三 2 b 李四 4 d 3 c
------解决方案--------------------
再加个过滤条件
select A.id,B.name1,c.name2
form A
right join B on B.主表ID = A.id
left join C on C.主表ID = A.id
where A.id = 1
------解决方案--------------------
create table A(id number(10),name varchar2(20));
insert into A values(1,'aa');
insert into A values(2,'bb');
create table B(主表id number(10),id number(10),name1 varchar2(20));
insert into B values(1,1,'a');
insert into B values(1,2,'b');
insert into B values(1,3,'c');
insert into B values(1,4,'d');
create table C(主表id number(10),id number(10),name2 varchar2(20));
insert into C values(1,1,'张三');
insert into C values(1,2,'李四');
select B.主表ID, B.Name1,C.name2 from A,B,C where A.id(+) = B.id and B.id=C.id(+);