经常看到开发人员在SQL中写左连接或右连接,其实有时候是失效的。下面来做个试验
create table t( a number);
create table t1(b number);
insert into t values(1);
insert into t values(2);
insert into t values(3);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
commit;
SQL> select * from t;
A
----------
1
2
3
SQL> select * from t1;
B
----------
2
3
4
SQL> select * from t,t1 where a=b;
A B
---------- ----------
2 2
3 3
SQL> select * from t,t1 where a=b(+);
A B
---------- ----------
2 2
3 3
1
--可以看到加不加连接符结果都一样。
SQL> select * from t,t1 where a=b(+) and b>1;
A B
---------- ----------
2 2
3 3
SQL> select * from t,t1 where a=b and b>1;
A B
---------- ----------
2 2
3 3