有这样两个表:
一、
sql语句:
select * from tbl_dept a inner join tbl_emp b on a.id = b.depId;
二、
sql语句:
select * from tbl_dept a left join tbl_emp b on a.id=b.deptId;
扫描二维码关注公众号,回复:
46357 查看本文章
三、
sql语句
select * from tbl_dept a right join tbl_emp b on a.id = b.deptId;
四、
sql语句:
select * from tbl_dept a left join tbl_emp b on a.id=b.deptId where b.deptId is null;
五、
sql语句
select * from tbl_dept a right join tbl_emp b on a.id=b.deptId where a.id is null;
六、
sql语句
select * from tbl_dept a right join tbl_emp b on a.id=b.deptId
union
select * from tbl_dept a left join tbl_emp b on a.id=b.deptId;
七、
sql语句
select * from tbl_dept a right join tbl_emp b on a.id=b.depId where a.id is null
union
select * from tbl_dept a left join tbl_emp b on a.id=b.depId where b.deptId is null;