zoukankan      html  css  js  c++  java
  • full join ,left join ,right join,inner join

    full join ,left join ,right join,inner join

    一、full  join 

    ----- full join
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A
      FULL JOIN (SELECT 4 AS T1
                   FROM DUAL
                 UNION
                 SELECT 3 AS T1 FROM DUAL) B
        ON A.T1 = B.T1

    二、left  join 

    ---- left join 
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A
      LEFT JOIN (SELECT 4 AS T1
                   FROM DUAL
                 UNION
                 SELECT 3 AS T1 FROM DUAL) B
        ON A.T1 = B.T1
    
    ----相当于
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A,
           (SELECT 4 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) B
     WHERE A.T1 = B.T1(+)
      

    三、rightjoin 

    ---- right join 
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A
      RIGHT JOIN (SELECT 4 AS T1
                   FROM DUAL
                 UNION
                 SELECT 3 AS T1 FROM DUAL) B
        ON A.T1 = B.T1
    
    ----相当于
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A,
           (SELECT 4 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) B
     WHERE A.T1(+) = B.T1

    四、inner  join 

    ---- inner join 
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A
      INNER JOIN (SELECT 4 AS T1
                   FROM DUAL
                 UNION
                 SELECT 3 AS T1 FROM DUAL) B
        ON A.T1 = B.T1
    
    ----相当于
    
    SELECT A.*, B.*
      FROM (SELECT 0 AS T1
              FROM DUAL
            UNION
            SELECT 1 AS T1
              FROM DUAL
            UNION
            SELECT 2 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) A,
           (SELECT 4 AS T1
              FROM DUAL
            UNION
            SELECT 3 AS T1 FROM DUAL) B
     WHERE A.T1 = B.T1
  • 相关阅读:
    rabbitmq线上服务器与项目结合的问题总结
    关于RabbitMQ Queue Argument的简介
    rabbitmq代码配置
    python基础篇17-虚环境
    Java-实体与集合转换
    Java-精确计算工具类
    Java-汉字繁体拼音转换
    Java-集合条件筛选
    Java-发邮件
    Java-MD5
  • 原文地址:https://www.cnblogs.com/wml-it/p/13650610.html
Copyright © 2011-2022 走看看