Oracle连接查询
--交叉连接(会产生笛卡尔积)
select * from emp cross join dept;
--自然连接(可自动匹配关联字段并消除笛卡尔积)
select * from emp natural join dept;
--JOIN...USING,USING子句后跟关联的字段
select * from emp e join dept using(deptno);
--JOIN...ON,ON子句后面跟关联的条件
select * from emp e join salgrade s on (e.sal between s.losal and s.hisal);
--左外连接LEFT OUTER JOIN...ON
select * from emp e left outer join dept d on (e.deptno = d.deptno);
--左外连接也可以写成这样:
select * from emp e ,dept d where e.deptno = d.deptno(+);
--右外连接RIGHT OUTER JOIN...ON
select * from emp e right outer join dept d on (e.deptno = d.deptno);
--右外连接也可以写成这样:
select * from emp e ,dept d where e.deptno(+) = d.deptno;
--全外连接FULL OUTER JOIN
select * from emp e full outer join dept d on (e.deptno = d.deptno);