标签:order by left join 筛选 tno dep 链接 order 1.0 bsp
select e.ename,d.deptno,d.dname,d.loc
from dept d left join emp e
on(d.deptno = e.deptno
and (e.deptno=10 or e.deptno=20))
order by 2;
另外,还可以先用emp.deptno进行筛选,然后进行外部联接:
select e.ename,d.deptno,d.dname,d.loc
from dept d
left join
(select ename,deptno
from emp
where deptno in (10,20)
) e on (e.deptno =d.deptno)
order by 2;
标签:order by left join 筛选 tno dep 链接 order 1.0 bsp
原文地址:http://www.cnblogs.com/liang545621/p/7523379.html