DROP TABLE IF EXISTS `tab_id_index`; CREATE TABLE `tab_id_index` ( `id` int(11) NOT NULL DEFAULT '0', `name` varchar(10) DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- ---------------------------- -- Records of tab_id_index -- ---------------------------- INSERT INTO `tab_id_index` VALUES ('1', '3', '12'); INSERT INTO `tab_id_index` VALUES ('2', '3', '12'); INSERT INTO `tab_id_index` VALUES ('3', '3', '12'); INSERT INTO `tab_id_index` VALUES ('5', '4', '14');
DROP TABLE IF EXISTS `tab_no_index`; CREATE TABLE `tab_no_index` ( `id` int(11) NOT NULL DEFAULT '0', `name` varchar(10) DEFAULT NULL, `age` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- ---------------------------- -- Records of tab_no_index -- ---------------------------- INSERT INTO `tab_no_index` VALUES ('1', '1', '12'); INSERT INTO `tab_no_index` VALUES ('2', '1', '12'); INSERT INTO `tab_no_index` VALUES ('3', '3', '12'); INSERT INTO `tab_no_index` VALUES ('4', '6', '14');
select * from tab_id_index a,tab_no_index b where a.id = b.id;sql
同:spa
select * from tab_id_index a INNER JOIN tab_no_index b ON a.id = b.id;3d
select * from tab_id_index a LEFT JOIN tab_no_index b ON a.id = b.id;code
同:blog
select * from tab_id_index a LEFT OUTER JOIN tab_no_index b ON a.id = b.id;table
select * from tab_id_index a RIGHT JOIN tab_no_index b ON a.id = b.id; class
同:select
select * from tab_id_index a RIGHT OUTER JOIN tab_no_index b ON a.id = b.id;im