`

外连接

 
阅读更多

看代码的过程中 突然冒了个(+)出来,原来这是外连接的简写

select a.*,b.* from tableA a left join tableB b on a.id=b.id
等价于
select a.*,b.* from tableA a,tableB b where a.id=b.id(+)

这个表示选择所有tableA的记录,如果不满足a.id=b.id的tableB的相关值全部为null

a.id  a.name  b.id  b.school
1      abc     1      whut
2      cde     null   null

右外连接
select a.*,b.* from tableA a right join tableB b on a.id=b.id
等价于
select a.*,b.* from tableA a,tableB b where a.id(+)=b.id

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics