MySQL 的七种 Join

创建表

快速到底

学生表

create table student(  
  id int(11) not null AUTO_INCREMENT,
  name varchar(30),
  address varchar(40),
  primary key (id)
) engine=innodb charset=utf8;

INSERT INTO student(name,address) VALUES(田开智,安徽省天长市);
INSERT INTO student(name,address) VALUES(陶沪生,安徽省铜陵市);
INSERT INTO student(name,address) VALUES(石冬冬,安徽省安庆市);
INSERT INTO student(name,address) VALUES(魏忠原,安徽省滁州市);
INSERT INTO student(name,address) VALUES(田永恒,安徽省阜阳市);
INSERT INTO student(name,address) VALUES(熊发挥,安徽省天长市);

 成绩表

create table chengji(  
  id int(11) not null AUTO_INCREMENT,
  socre float(5,2),
  primary key (`id`)
) engine=innodb charset=utf8;

INSERT INTO chengji(socre) VALUES(95.54);
INSERT INTO chengji(socre) VALUES(124.4);
INSERT INTO chengji(socre) VALUES(130.0);
INSERT INTO chengji(socre) VALUES(135);
INSERT INTO chengji(socre) VALUES(149.547);

INSERT INTO chengji(id,socre) VALUES(7,140);

内链接

内链接文氏图

 

左外连接

左外连接文氏图

 

右外连接

右外连接文氏图

 

左连接

左连接文氏图

 

右连接

连接文氏图

 

全连接

全连接文氏图

 

去掉交集

文氏图