目录

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;

外连接

https://i-blog.csdnimg.cn/direct/0b23d0ad6be94a098472991df8b0ea36.png

注:本图取自博客园大佬" 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