多表查询:
#一、内连接查询#
select sal from emp join dept
on(emp.DEPTNO=dept.DEPTNO);
#二、外连接查询#
#1、左外连接
select emp.sal,emp.DEPTNO from emp left join dept
on(emp.DEPTNO=dept.DEPTNO);
#2、右外连接
select emp.sal,emp.DEPTNO from emp right join dept
on(emp.DEPTNO=dept.DEPTNO);
#三、自连接查询#
select e1.EMPNO '员工工号',e1.ENAME '员工姓名',e2.EMPNO '领导工号',e2.ENAME '领导姓名' from emp e1 left join emp e2
on(e1.mgr=e2.EMPNO);