ORACLE SQL 多表查询
开发工具与关键技术:Oracle sql*plus 与 PLSQL Developer
作者:蒋紫晨
撰写时间:2019年04月07日
外连接
例子1、如果别人要的数据是那个部门没有员工?
Select * from departments d , employees e
where e.department_id(+)= d.department_id
and e.employee_id is null;
-------------------------------------------------------
SQL1999语法:
Select * from departments d Left join employees e
On d.department_id= e.department_id
Where e.employee_id is null;
我们所想的就是把全部的部门全都写出啦,在连接那个员工对应那个部门。
空的部门就不会有员工显示。解析下(+)在左边就是以右边为主表
例子2、所有员工那个没有分配部门的员工?
Select * from departments d , employees e
where e.department_id= d.department_id(+)
and e.depart