看代码的过程中 突然冒了个(+)出来,原来这是外连接的简写
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
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
本文详细介绍了SQL中外连接的使用方法,包括左外连接和右外连接,并通过具体例子展示了其等价转换方式。左外连接会选择所有tableA的记录,对于不匹配的部分,tableB的相关值将显示为null。而右外连接则是选择所有tableB的记录。
215

被折叠的 条评论
为什么被折叠?



