1 A, B two tables altogether select * from Tbl_emp a inner joins tbl_dept b on a.deptid = B.id;2 A, b two tables shared +a unique select * FROM Tbl_emp a LEFT join Tbl_dept b on a.deptid = B.id;3 A, b two table unique SELECT * FROM Tbl_emp a right join tbl_dept b on a.deptid = b.id;4 a exclusive Select * FROM Tbl_emp a LEFT join tbl_dept b in a.deptid = b.ID where b.id is null;5 B's exclusive select * from Tbl_emp a right join tbl_d EPT b on a.deptid = b.id where a.deptid is null; #B的独有6 AB all #mysql full join implementation because MySQL does not support full join, here is an alternative #left JOIN + Union (can remove duplicate data) + right Joinselect * from Tbl_emp A L EFT join Tbl_dept b on a.deptid = B.idunionselect * from tbl_emp A right joins tbl_dept B on a.deptid = B.id7 a unique +b exclusive Sele CT * FROM Tbl_emp a LEFT join tbl_dept b on a.deptid = b.ID WHERE b. ' id ' was nullunionselect * from Tbl_emp a RIGHT join TB L_dept B on a.deptid = b.id WHERE A. ' DeptID ' is NULL;
MySQL Seven common join queries