标签:inner 分享图片 src create info bubuko sts 分享 utf8
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;
同:
select * from tab_id_index a INNER JOIN tab_no_index b ON a.id = b.id;
select * from tab_id_index a LEFT JOIN tab_no_index b ON a.id = b.id;
同:
select * from tab_id_index a LEFT OUTER JOIN tab_no_index b ON a.id = b.id;
select * from tab_id_index a RIGHT JOIN tab_no_index b ON a.id = b.id;
同:
select * from tab_id_index a RIGHT OUTER JOIN tab_no_index b ON a.id = b.id;
标签:inner 分享图片 src create info bubuko sts 分享 utf8
原文地址:https://www.cnblogs.com/bestzhang/p/10283660.html