时间:2021-07-01 10:21:17 帮助过:4人阅读
插入数据
/*插入数据*/ INSERT INTO tbl_dept(deptName,locAdd) VALUES(‘RD‘,11); INSERT INTO tbl_dept(deptName,locAdd) VALUES(‘HR‘,12); INSERT INTO tbl_dept(deptName,locAdd) VALUES(‘MK‘,13); INSERT INTO tbl_dept(deptName,locAdd) VALUES(‘MIS‘,14); INSERT INTO tbl_dept(deptName,locAdd) VALUES(‘FD‘,15); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘z3‘,1); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘z4‘,1); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘z5‘,1); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘w5‘,2); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘w6‘,2); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘s7‘,3); INSERT INTO tbl_emp(NAME,deptId) VALUES(‘s8‘,4);View Code
‘tbl_dept‘表和‘tbl_emp‘表
一、内连接
内连接文氏图
select * from tbl_dept a inner join tbl_emp b on a.id=b.deptId;
二、左外连接
左外连接文氏图
select * from tbl_dept a left join tbl_emp b on a.id=b.deptId;
三、右外连接
右外连接文氏图
select * from tbl_dept a right join tbl_emp b on a.id=b.deptId;
四、左连接
左连接文氏图
select * from tbl_dept a left join tbl_emp b on a.id=b.deptId where b.deptId is null;
五、右连接
右连接文氏图
select * from tbl_dept a right join tbl_emp b on a.id=b.deptId where a.id is null;
六、全连接
全连接文氏图
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;
文氏图
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;
【知识库】-数据库_MySQL 的七种 join
标签:文章 外连接 key sel inf img inner 数据库 close