全部博文(101)
分类: Oracle
2012-07-26 13:43:41
比如说表a有字段name, id,有两个记录
水1,1
水2,2
水3,3
表b有字段name, salary,有两个记录
水1,0.00001
水2,0.00001
水4,0.00004
select a.name, a.id, b.salary from a, b where a.name=b.name;
结果是
水1,1,0.00001
水2,2,0.00001
select a.name, a.id, b.salary from a, b where a.name=b.name(+);
结果是
水1,1,0.00001
水2,2,0.00001
水3,3
select a.name, a.id, b.salary from a, b where b.name(+)=a.name;
结果是
水1,1,0.00001
水2,2,0.00001
水3,3
select a.name, a.id, b.salary from a, b where a.name(+)=b.name;
结果是
水1,1,0.00001
水2,2,0.00001
0.00004
所以无论左右连接怎么叫,只要记住(+)在哪边,哪边的所选项不足就要“+”(添加)空白项补足记录