1 DROP TABLE IF EXISTS `w1`; 2 CREATE TABLE `w1` ( 3 `waid` int(11) NOT NULL AUTO_INCREMENT, 4 `wa1` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 5 `wa2` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 6 PRIMARY KEY (`waid`) 7 ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 8 9 -- ---------------------------- 10 -- Records of w1 11 -- ---------------------------- 12 INSERT INTO `w1` VALUES (‘1‘, ‘w1-1‘, ‘1‘); 13 INSERT INTO `w1` VALUES (‘2‘, ‘w1-2‘, ‘2‘);
1 DROP TABLE IF EXISTS `w2`; 2 CREATE TABLE `w2` ( 3 `wbid` int(11) NOT NULL AUTO_INCREMENT, 4 `wb1` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 5 `wb2` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL, 6 PRIMARY KEY (`wbid`) 7 ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; 8 9 -- ---------------------------- 10 -- Records of w2 11 -- ---------------------------- 12 INSERT INTO `w2` VALUES (‘1‘, ‘w2-1‘, ‘2‘); 13 INSERT INTO `w2` VALUES (‘2‘, ‘w2-2‘, ‘2‘);
1 SELECT * FROM w1 LEFT JOIN w2 ON w1.wa2=w2.wb2 2 SELECT * FROM w1 LEFT JOIN w2 ON w2.wb2=w1.wa2 3 4 SELECT * FROM w2 RIGHT JOIN w1 ON w1.wa2=w2.wb2 5 SELECT * FROM w2 RIGHT JOIN w1 ON w2.wb2=w1.wa2 6 7 8 SELECT * FROM w2 LEFT JOIN w1 ON w1.wa2=w2.wb2 9 SELECT * FROM w2 LEFT JOIN w1 ON w2.wb2=w1.wa2 10 11 SELECT * FROM w1 RIGHT JOIN w2 ON w1.wa2=w2.wb2 12 SELECT * FROM w1 RIGHT JOIN w2 ON w2.wb2=w1.wa2 13 14 15 SELECT * FROM w1 INNER JOIN w2 ON w1.wa2=w2.wb2 16 SELECT * FROM w1 INNER JOIN w2 ON w2.wb2=w1.wa2 17 SELECT * FROM w1 CROSS JOIN w2 ON w1.wa2=w2.wb2 18 SELECT * FROM w1 CROSS JOIN w2 ON w2.wb2=w1.wa2 19 20 SELECT * FROM w2 INNER JOIN w1 ON w1.wa2=w2.wb2 21 SELECT * FROM w2 INNER JOIN w1 ON w2.wb2=w1.wa2 22 SELECT * FROM w2 CROSS JOIN w1 ON w1.wa2=w2.wb2 23 SELECT * FROM w2 CROSS JOIN w1 ON w2.wb2=w1.wa2
时间: 2024-10-12 02:04:58