mysql 7种JOIN理论,看完你就懂了
Posted 张铎(信念)
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 7种JOIN理论,看完你就懂了相关的知识,希望对你有一定的参考价值。
select * from tbl_emp a inner join tbl_dept b on a.deptId=b.id;
select * from tbl_emp a LEFT JOIN tbl_dept b on a.deptId=b.id;
select * from tbl_emp a RIGHT JOIN tbl_dept b on a.deptId=b.id;
select * from tbl_emp a LEFT JOIN tbl_dept b on a.deptId=b.id where b.id is null;
select * from tbl_emp a RIGHT JOIN tbl_dept b on a.deptId=b.id where a.id is null;
select * from tbl_emp a LEFT JOIN tbl_dept b on a.deptId=b.id union select * from tbl_emp a RIGHT JOIN tbl_dept b on a.deptId=b.id;
select * from tbl_emp a LEFT JOIN tbl_dept b on a.deptId=b.id where b.id is null union select * from tbl_emp a RIGHT JOIN tbl_dept b on a.deptId=b.id where a.id is null;
以上是关于mysql 7种JOIN理论,看完你就懂了的主要内容,如果未能解决你的问题,请参考以下文章