create table t1(id varchar2(50),name varchar2(50));
create table t2(id varchar2(50),name varchar2(50));
insert into t1 values ('1','a');
insert into t1 values ('2','b');
insert into t1 values ('3','c');
insert into t2 values ('1','d');
insert into t2 values ('4','f');
select * from t1,t2 where t1.id=t2.id(+) and t2.name='d' --t2.name 不加(+)
ID NAME ID NAME
----------------------------------- --
1 a 1 d
select * from t1,t2 where t1.id=t2.id(+) and t2.name(+)='d' --t2.name 加(+)
ID NAME ID NAME
---------------- ---------------------
1 a 1 d
3 c
2 b
------解决方案-------------------- 顶这个呀:
------解决方案-------------------- select a.dname,b.ename from dept a,emp b where a.deptno=b.deptno(+) and b.deptno(+)=10 像这种的b表每个字段都要加(+)的,因为如果不加的话相当于对b表直接过滤了,那就跟全没加(+)号一样了,变成了等值连接,不等值的b表行全抛弃。
------解决方案--------------------
------解决方案-------------------- 除了连接条件加(+) 如果其他条件是针对从表的,那应该加(+) 就相当于 select * from t1,t2 where t1.id=t2.id(+) and t2.name='d' --t2.name 不加(+) 同 select * from t1 left join t2 on t1.id=t2.id where t2.name='d'
select * from t1,t2 where t1.id=t2.id(+) and t2.name(+)='d' --t2.name 加(+) 同 select * from t1 left join t2 on t1.id=t2.id and t2.name='d'