zoukankan      html  css  js  c++  java
  • 各种SQL连接符Join

    一、连接符分类,内连接,外连接

    1、内连接:Inner Join简写Join。

    2、外连接:Left Outer Join 简写Left Join;Right Outer Join 简写Right Join;Full Outer Join 简写Full Join。

    二、用集合的形式展示各个连接符的特点

    1、准备测试表Test_StudentA,Test_StudentB

    2、Join,返回Test_StudentA与Test_StudentB集合的交集。

    3、Left Join, 返回左表Test_StudentA的全集,右表匹配连接条件有值,不匹配赋NULL值。

    4、Right Join,返回右表Test_StudentB的全集,左表匹配连接条件有值,不匹配赋NULL值。

    5、Full Join,返回左表Test_StudentA,右表Test_StudentB的全集,不匹配连接条件赋NULL值。

    三、数据库中展现Join,Left Join,Right Join,Full Join的不同

    1、Join,返回左表与右表符合ON连接条件的行。

    如:select * from Test_StudentA join Test_StudentB on Test_StudentA.id=Test_StudentB.id

    2、Left Join, 以左表为基表,返回左表所有行。若右表不符合ON连接条件,则对应的字段赋NULL值。

    如:select * from Test_StudentA left join Test_StudentB on Test_StudentA.id=Test_StudentB.id

    3、Right Join,以右表为基表,返回右表所有行。若左表不符合ON连接条件,则对应的字段赋NULL值。

    如:select * from Test_StudentA right join Test_StudentB on Test_StudentA.id=Test_StudentB.id

    4、Full Join,返回左右表所有行,不符合on条件的字段赋NULL值。

    如:select * from Test_StudentA full join Test_StudentB on Test_StudentA.id=Test_StudentB.id

  • 相关阅读:
    Struts2完全解耦和
    storm 错误汇总
    sublime3 在ubuntu下不能输入中文
    sublime3 10款必备插件
    sublime3 SublimeREPL python3
    sublime3 Package Control不能使用
    Buffer ByteBuffer 缓冲区
    redis cluster批量插入
    延期执行的方案计策略汇总
    linux 免密登录
  • 原文地址:https://www.cnblogs.com/handhead/p/11097248.html
Copyright © 2011-2022 走看看