INNER LEFT RIGHT JOIN语句_MySQL
程序员文章站
2022-06-16 08:50:27
...
bitsCN.com
INNER LEFT RIGHT JOIN语句 Sql代码 CREATE TABLE `a` ( `a1` VARCHAR(10) DEFAULT NULL, `b1` VARCHAR(10) DEFAULT NULL, `c1` VARCHAR(10) DEFAULT NULL ) ENGINE=INNODB DEFAULT CHARSET=utf8 CREATE TABLE `b` ( `a2` VARCHAR(10) DEFAULT NULL, `b2` VARCHAR(10) DEFAULT NULL ) ENGINE=INNODB DEFAULT CHARSET=utf8 创建出表,表内数据如下: SQL语句执行结果图片在语句的下方 Sql代码 #inner join SELECT A.*,B.* FROM a INNER JOIN B ON a.a1=b.a2 Sql代码 #left join SELECT A.*,B.* FROM a LEFT OUTER JOIN b ON a.a1 = b.a2 Sql代码 #right join SELECT A.*,B.* FROM a RIGHT OUTER JOIN b ON a.a1 = b.a2 Sql代码 #full outer join union SELECT A.*,B.* FROM a LEFT OUTER JOIN b ON a.a1 = b.a2 UNION SELECT A.*,B.* FROM a RIGHT OUTER JOIN b ON a.a1 = b.a2 Sql代码 SELECT A.*, B.* FROM A,B Sql代码 SELECT A.*,B.* FROM a JOIN b ON a.a1 = b.a2 默认是inner join
bitsCN.com
INNER LEFT RIGHT JOIN语句 Sql代码 CREATE TABLE `a` ( `a1` VARCHAR(10) DEFAULT NULL, `b1` VARCHAR(10) DEFAULT NULL, `c1` VARCHAR(10) DEFAULT NULL ) ENGINE=INNODB DEFAULT CHARSET=utf8 CREATE TABLE `b` ( `a2` VARCHAR(10) DEFAULT NULL, `b2` VARCHAR(10) DEFAULT NULL ) ENGINE=INNODB DEFAULT CHARSET=utf8 创建出表,表内数据如下: SQL语句执行结果图片在语句的下方 Sql代码 #inner join SELECT A.*,B.* FROM a INNER JOIN B ON a.a1=b.a2 Sql代码 #left join SELECT A.*,B.* FROM a LEFT OUTER JOIN b ON a.a1 = b.a2 Sql代码 #right join SELECT A.*,B.* FROM a RIGHT OUTER JOIN b ON a.a1 = b.a2 Sql代码 #full outer join union SELECT A.*,B.* FROM a LEFT OUTER JOIN b ON a.a1 = b.a2 UNION SELECT A.*,B.* FROM a RIGHT OUTER JOIN b ON a.a1 = b.a2 Sql代码 SELECT A.*, B.* FROM A,B Sql代码 SELECT A.*,B.* FROM a JOIN b ON a.a1 = b.a2 默认是inner join
bitsCN.com
推荐阅读
-
oracle中left join和right join的区别浅谈
-
MySQL 8.0.18 Hash Join不支持left/right join左右连接问题
-
MySQL内连接(INNER JOIN)
-
MySQL利用profile分析慢sql详解(group left join效率高于子查询)
-
Oracle数据库INNER JOIN语句、LEFT JOIN语句、RIGHT JOIN语句等使用学习
-
SQL 外链接操作小结 inner join left join right join
-
MSSQL内外连接(INNER JOIN)语句详解
-
MySQL优化--NOT EXISTS和LEFT JOIN方式差异
-
inner join 内联与left join 左联的实例代码
-
数据库中的左连接(left join)和右连接(right join)区别