MySQL JOIN
2024.6.30
1.INNER JOIN:取交集
2024.7.4
1.JOIN等价于INNER JOIN,相同的key匹配上时会产生笛卡尔积!
举个例子
Mysql中表student_table(id,name,birth,sex),插入如下记录:
('1004' , '张三' ,'2000-08-06' , '男');
('1009' , '李四', '2000-01-01', '男');
('1010' , '李四', '2001-01-01', '男');
('1006' , '王五', '2000-08-06' , '女');
('1008' , '张三', '2002-12-01', '女');
('1012' , '张三', '2001-12-01', '女');
('1011' , '李四', '2002-08-06' , '女');
('1009' , '李四', '2000-01-01', '男');
('1010' , '李四', '2001-01-01', '男');
('1006' , '王五', '2000-08-06' , '女');
('1008' , '张三', '2002-12-01', '女');
('1012' , '张三', '2001-12-01', '女');
('1011' , '李四', '2002-08-06' , '女');
执行
select t1.*,t2.* from ( select * from student_table where sex = '男' ) t1 join (select * from student_table where sex = '女')t2 on t1.name = t2.name ;
结果是
2024.7.9
1.MySQL不支持 FULL JOIN