SQL99-多表查询
目录
SQL99 多表查询
内连接:
select name, depart_name, city
from employee e join department d
on e.depart_id = d.depart_id
join location l
on d.locat_id = l.locat_id;
外连接
注:本图取自博客园大佬" anliux “的博客,原帖链接:
最下边两种查询情况需要用关键字"union all"进行连表,这里以左边满外连接为例:
select ......
from 表1 as a
left join 表2 as b
on a.列名 = b.列名
union all
select ......
from 表1 as a
right join 表2 as b
on a.列名 = b.列名
where a.列名 is null