mysql> select * from test;
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | .12xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec) mysql> select * from user;
+------+----------+-----------+
| id | name | address |
+------+----------+-----------+
| | xiaoming | beijing |
| | xiaobai | shandong |
| | xiaohong | suzhou |
| | xiaohei | changchun |
+------+----------+-----------+
rows in set (0.00 sec) mysql> select * from user left join test on user.name=test.name;
+------+----------+-----------+------+----------+-------+-----------+
| id | name | address | id | name | score | subject |
+------+----------+-----------+------+----------+-------+-----------+
| | xiaoming | beijing | | xiaoming | | shuxue |
| | xiaohong | suzhou | | xiaohong | | shuxue |
| | xiaohong | suzhou | | xiaohong | | english |
| | xiaohong | suzhou | | xiaohong | | physics |
| | xiaohong | suzhou | | xiaohong | | astronaut |
| | xiaoming | beijing | | xiaoming | | physics |
| | xiaoming | beijing | | xiaoming | | astronaut |
| | xiaoming | beijing | | xiaoming | | english |
| | xiaobai | shandong | | xiaobai | | astronaut |
| | xiaohei | changchun | | xiaohei | | shuxue |
| | xiaohei | changchun | | xiaohei | | physics |
+------+----------+-----------+------+----------+-------+-----------+
rows in set (0.00 sec) mysql> select * from user right join test on user.name=test.name;
+------+----------+-----------+----+------------+-------+-----------+
| id | name | address | id | name | score | subject |
+------+----------+-----------+----+------------+-------+-----------+
| | xiaoming | beijing | | xiaoming | | shuxue |
| | xiaoming | beijing | | xiaoming | | physics |
| | xiaoming | beijing | | xiaoming | | astronaut |
| | xiaoming | beijing | | xiaoming | | english |
| | xiaobai | shandong | | xiaobai | | astronaut |
| | xiaohong | suzhou | | xiaohong | | shuxue |
| | xiaohong | suzhou | | xiaohong | | english |
| | xiaohong | suzhou | | xiaohong | | physics |
| | xiaohong | suzhou | | xiaohong | | astronaut |
| | xiaohei | changchun | | xiaohei | | shuxue |
| | xiaohei | changchun | | xiaohei | | physics |
| NULL | NULL | NULL | | .2xiaobai | | english |
| NULL | NULL | NULL | | .2xiaobai | | physics |
| NULL | NULL | NULL | | 3xiaobai | | shuxue |
| NULL | NULL | NULL | | 123xiaohei | | astronaut |
| NULL | NULL | NULL | | .12xiaohei | | english |
+------+----------+-----------+----+------------+-------+-----------+
rows in set (0.00 sec)

mysql 左联结与右联结的更多相关文章

  1. MySQL的查询,子查询,联结查询,联合查询

    MySQL的查询,子查询,联结查询,联合查询 一.mysql查询的五种子句where(条件查询).having(筛选).group by(分组).order by(排序).limit(限制结果数) 二 ...

  2. 【转】mysql数据库中实现内连接、左连接、右连接

    [转]mysql数据库中实现内连接.左连接.右连接 内连接:把两个表中数据对应的数据查出来 外连接:以某个表为基础把对应数据查出来 首先创建数据库中的表,数据库代码如下: /* Navicat MyS ...

  3. 深入浅出:MySQL的左连接、右连接、内连接

    http://blog.csdn.net/wyzxg/article/details/7276979 三种连接的语法 为便于更多的技友快速读懂.理解,我们只讨论2张表对象进行连接操作的情况,大于2张表 ...

  4. mysql左连接 右连接 内连接的区别

    mysql左连接 右连接 内连接的区别 1.内连接,显示两个表中有联系的所有数据; 2.左链接,以左表为参照,显示所有数据,右表中没有则以null显示 3.右链接,以右表为参照显示数据,,左表中没有则 ...

  5. mysql执行顺序及左连接和右连接

    SELECT语句执行顺序 SELECT语句中子句的执行顺序与SELECT语句中子句的输入顺序是不一样的,所以并不是从SELECT子句开始执行的,而是按照下面的顺序执行: 开始->FROM子句-& ...

  6. mysql之内连接,外连接(左连接,右连接),union,union all的区别

    内连接,外连接,左连接,右连接,全连接 测试数据: CREATE TABLE `a_table` ( `a_id` int(11) DEFAULT NULL, `a_name` varchar(10) ...

  7. mysql之左连接、右连接、内连接、全连接、等值连接、交叉连接等

    mysql中的各种jion的记录,以备用时查 1.等值连接和内连接, a.内连接与等值连接效果是相同的,执行效率也相同,只是书写方式不一样,内连接是由SQL 1999规则定的书写方式 比如: sele ...

  8. 细说MySQL连接查询:内连、左连和右连

    转: 细说MySQL连接查询:内连.左连和右连 简介: MySQL 的连接查询,通常都是将来自两个或多个表的行结合起来,基于这些表之间的共同字段,进行数据的拼接.首先,要确定一个主表作为结果集,然后将 ...

  9. 深入浅出:MySQL的左连接、右连接、等值连接

    深入浅出:MySQL的左连接.右连接.等值连接 三种连接的语法 为便于更多的技友快速读懂.理解,我们只讨论2张表对象进行连接操作的情况,大于2张表对象进行的连接操作原理也是一样的. 1.左连接(LEF ...

随机推荐

  1. python ocr中文识别库 tesseract安装及问题处理

    这个破东西,折腾了快1个小时,网上的教材太乱了. 我解决的主要是windows的问题 先下载exe.(一看到这个,我就有种预感,不妙) https://digi.bib.uni-mannheim.de ...

  2. 2019-07-25 PDO

    PDO是什么? pdo是php数据对象,即php data object .使用pdo是为了让我们能够使用相同的代码连接不同的数据库.PDO扩展是以面向对象的方式来进行封装,也就是说,我们的PDO扩展 ...

  3. k8s--complete-demo.yaml

  4. 拓展 - Webrtc 的回声抵消(aec、aecm)算法简介

    webrtc 的回声抵消(aec.aecm)算法简介 原文链接:丢失.不好意思        webrtc 的回声抵消(aec.aecm)算法主要包括以下几个重要模块:1.回声时延估计 2.NLMS( ...

  5. js中cssText批量修改元素样式

    平常编写代码,更改一个元素样式的时候,自己都是用 obj.style.width = "200px"; obj.style.position = "absolute&qu ...

  6. 【WPF】EntityframeworkCore Update注意事项

    The instance of entity type 'Book' cannot be tracked because another instance with the same key valu ...

  7. leetcode 学习心得 (2) (301~516)

    源代码地址:https://github.com/hopebo/hopelee 语言:C++ 301. Remove Invalid Parentheses Remove the minimum nu ...

  8. 大数据之kafka-05.讲聊聊Kafka的版本号

    今天聊聊kafka版本号的问题,这个问题实在是太重要了,我觉得甚至是日后能否用好kafka的关键.上一节我们介绍了kafka的几种发行版,其实不论是哪种kafka,本质上都内嵌了最核心的Apache ...

  9. Web渗透

  10. 谈谈OAuth1,OAuth2异同

    ##一.写在前面在收集资料时,我查询和学习了许多介绍OAuth的文章,这些文章有好有坏,但大多是从个例出发.因此我想从官方文档出发,结合在stackoverflow上的一些讨论,一并整理一下.整理的内 ...