Oracle inner join、left join、right join 、+左边或者右边的区别
2017-08-16 11:21
429 查看
本文转自helong的文摘
这两张表 dept是主表 emp是子表,关联的列是deptno
dept表现有数据
emp表现有数据
inner join 意思是内连接 把匹配的信息全部查出来
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e innerjoin dept
d on e.deptno=d.deptno orderby e.empno;
查询的结果:
left join 左连接 意思是包含左边表所有记录,右边所有的匹配的记录,如果没有则用空补齐
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e leftjoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL :这条SQL语句左边是EMP表 左连接结果查询出EMP所有的记录,然后根据左边表匹配出右边表DEPT所有的记录
查询结果如下:
right join 右连接 意思是包括右边表所有记录,匹配左边表的记录,如果没有则以空补齐
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e rightjoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL:这条SQL语句EMP在左边,DEPT在右边,然后我们采用右连接,就查出右边表所有的数据
查询结构:
full join 全连接 意思是左右表所有的记录全部显示出来
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e fulljoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL:这条SQL语句采用全连接,查询出左表和右表所有的值出来
查询结果:
介绍Oracle +连接方式及说明
+在左边 为右连接
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e,dept d where e.deptno(+)=d.deptno orderby e.empno;
查询结果:
+在右边 为左连接
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname from emp
e,dept d where e.deptno=d.deptno(+) orderby e.empno;
查询结果:
原文地址:http://www.cnblogs.com/helong/articles/2088535.html
这两张表 dept是主表 emp是子表,关联的列是deptno
dept表现有数据
emp表现有数据
inner join 意思是内连接 把匹配的信息全部查出来
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e innerjoin dept
d on e.deptno=d.deptno orderby e.empno;
查询的结果:
left join 左连接 意思是包含左边表所有记录,右边所有的匹配的记录,如果没有则用空补齐
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e leftjoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL :这条SQL语句左边是EMP表 左连接结果查询出EMP所有的记录,然后根据左边表匹配出右边表DEPT所有的记录
查询结果如下:
right join 右连接 意思是包括右边表所有记录,匹配左边表的记录,如果没有则以空补齐
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e rightjoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL:这条SQL语句EMP在左边,DEPT在右边,然后我们采用右连接,就查出右边表所有的数据
查询结构:
full join 全连接 意思是左右表所有的记录全部显示出来
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e fulljoin dept
d on e.deptno=d.deptno orderby e.empno;
解释SQL:这条SQL语句采用全连接,查询出左表和右表所有的值出来
查询结果:
介绍Oracle +连接方式及说明
+在左边 为右连接
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname
from emp e,dept d where e.deptno(+)=d.deptno orderby e.empno;
查询结果:
+在右边 为左连接
SQL>select e.empno,e.ename,e.job,d.deptno,d.dname from emp
e,dept d where e.deptno=d.deptno(+) orderby e.empno;
查询结果:
原文地址:http://www.cnblogs.com/helong/articles/2088535.html
相关文章推荐
- Oracle inner join、left join、right join 、+左边或者右边的区别
- Oracle inner join、left join、right join 、+左边或者右边的区别
- oracle inner join、left join、right join 、+左边或者右边的区别
- Oracle inner join、left join、right join 、+左边或者右边的区别
- Oracle inner join、left join、right join 、+左边或者右边的区别
- oracle中left join和right join和inner join的区别
- left join 左边有数据,右边无数据,查询结果出现inner join的情况(and 和 where 的区别)
- Oracle_inner join,left join,right join,full join 的区别,用例子说明
- left join、right join、inner join的区别
- 转-sql之left join、right join、inner join的区别
- SQL中Left Join 与Right Join 与 Inner Join 与 Full Join的区别
- 图解SQL的inner join、left join、right join、full outer join、union、union all的区别
- inner join, left join, right join, full join 的区别
- sql之left join、right join、inner join的区别
- SQL的JOIN语法解析(inner join, left join, right join, full outer join的区别)
- inner join, left join, right join, full join 的区别
- 转sql之left join、right join、inner join的区别
- sql之left join、right join、inner join的区别
- sql之left join、right join、inner join的区别
- sql之left join、right join、inner join的区别