zoukankan      html  css  js  c++  java
  • 【Oracle&SQLServer】并集、交际、补集

    1、并集(UNION/UNION ALL)

    Oracle&SQLServer中用法一致

    UNION 去重
    UNION ALL 不去重
    -- 去重
    select * from tablea
    union
    select * from tableb
    
    -- 不去重
    select * from tablea
    union all
    select * from tableb

     2、交集(INTERSECT/EXISTS)

    Oracle&SQLServer中用法一致

    INTERSECT 去重
    EXISTS 不去重
    -- 去重
    select * from tablea
    intersect
    select * from tableb
    
    -- 不去重
    select * from tablea a
    where exists (select 1 from tableb b where a.ID=b.ID)

    3、补集(MINUS/EXCEPT/NOT EXISTS)

    Oracle:

    MINUS 去重
    NOT EXISTS 不去重

    SQLServer:

    EXCEPT 去重
    NOT EXISTS 不去重
    -- Oracle去重
    select * from tablea
    minus
    select * from tableb
    
    -- SQLServer去重
    select * from tablea
    except
    select * from tableb
    
    -- Oracle&SQLServer不去重
    select * from tablea a
    where not exists (select 1 from tableb b where a.ID=b.ID)
  • 相关阅读:
    Linux 套接字编程
    Linux 网络(连接)相关参数作用
    Python WSGI
    Ubuntu Cloud Image in Openstack
    AWK
    MySQL--开发技巧(一)
    spring MVC--配置注解
    javascript-JQuery样式篇(一)
    JSP--常用标签
    spring MVC basic
  • 原文地址:https://www.cnblogs.com/WillYang/p/3247386.html
Copyright © 2011-2022 走看看