ORACLE外连接小结~ http://blog.csdn.net/wh62592855/article/details/4852908

来源:互联网 发布:手游服务端源码 编辑:程序博客网 时间:2024/05/01 06:50
//table1和table2为两个测试表 随便插入几条数据   SQL> select * from table1;          ID NAME  ---------- --------------------           1 wh           2 wp           3 wq  SQL> select * from table2;          ID NAME  ---------- --------------------           4 wr           1 wh  //正常查询   SQL> select a.name,b.name    2  from table1 a,table2 b    3  where a.id=b.id;  NAME                 NAME  -------------------- --------------------  wh                   wh  //显示出table1中的所有记录 table2中无相应记录则置NULL   SQL> select a.name,b.name    2  from table1 a,table2 b    3  where a.id=b.id(+);  NAME                 NAME  -------------------- --------------------  wh                   wh  wq  wp  //显示出table2中的所有记录 table1中无相应记录则置NULL   SQL> select a.name,b.name    2  from table1 a,table2 b    3  where a.id(+)=b.id;  NAME                 NAME  -------------------- --------------------  wh                   wh                       wr  //呵呵,这里本想尝试一下全外连接,不过使用(+)好像不行   SQL> select a.name,b.name    2  from table1 a,table2 b    3  where a.id(+)=b.id(+);  where a.id(+)=b.id(+)               *  ERROR at line 3:  ORA-01468: a predicate may reference only one outer-joined table  




原创粉丝点击