zoukankan      html  css  js  c++  java
  • mysql 左右连接

    https://blog.csdn.net/rocling/article/details/90516802

    举例说明
    假设您有两个表,每个表只有一个列,表数据如下
    A B
    - -
    1 3
    2 4
    3 5
    4 6
    注意,(1,2)是A表唯一的,(3,4)是公共的,并且(5,6)是B表独有的

    内连接
    内连接是A表的所有行交上B表的所有行得出的结果集

    select * from a INNER JOIN b on a.a = b.b;
    select a.*, b.* from a,b where a.a = b.b;

    a | b
    --+--
    3 | 3
    4 | 4
    左外连接
    左外连接是A表的所有行匹配上B表得出的结果集

    select * from a LEFT OUTER JOIN b on a.a = b.b;
    select a.*, b.* from a,b where a.a = b.b(+);

    a | b
    --+-----
    1 | null
    2 | null
    3 | 3
    4 | 4
    右外连接
    右外连接是B表的所有行匹配上A表得出的结果集

    select * from a RIGHT OUTER JOIN b on a.a = b.b;
    select a.*, b.* from a,b where a.a(+) = b.b;

    a | b
    -----+----
    3 | 3
    4 | 4
    null | 5
    null | 6
    全连接
    全连接是A表的所有行并上B表的所有行得出的结果集

    select * from a FULL OUTER JOIN b on a.a = b.b;

    a | b
    -----+-----
    1 | null
    2 | null
    3 | 3
    4 | 4
    null | 6
    null | 5
     
    ————————————————
    版权声明:本文为CSDN博主「rocling」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/rocling/article/details/90516802

  • 相关阅读:
    Java实现 LeetCode 715 Range 模块(选范围)
    HTML 图像
    HTML 样式- CSS
    HTML <head>
    HTML 链接
    HTML 文本格式化
    目标检测中的anchor-based 和anchor free
    目标检测coco数据集点滴介绍
    Camera HDR Algorithms
    噪声标签的负训练:ICCV2019论文解析
  • 原文地址:https://www.cnblogs.com/lvcha/p/12090353.html
Copyright © 2011-2022 走看看