zoukankan      html  css  js  c++  java
  • Oracle 数据集合的并交差操作

    数据表TA ( id ) {1,2,4,5}

    数据表TB ( id ) {2,3,5,6,7}

    =========================================

    1.并集 union all -->得到 左表有的 加上 右表有的:

    select id from ta
    union all
    select id from tb;

    -----------------------------------------------------

    ID
    1
    2
    4
    5
    2
    3
    5
    6
    7

    =========================================

    2.并集 union -->得到 左表有的 加上 右表有的,然后剃重:

    select id from ta
    union
    select id from tb;

    -----------------------------------------------------

    ID
    1
    2
    3
    4
    5
    6
    7

    =========================================

    3.交集 intersect -->得到 左表和右表同时有的:

    select id from ta
    intersect
    select id from tb;

    -----------------------------------------------------

    ID
    2
    5

    =========================================

    4.差集 minus -->得到 左表有 但是右表没有的:

    select id from ta
    minus
    select id from tb;

    -----------------------------------------------------

    ID
    1
    4

    =========================================

  • 相关阅读:
    Win 及 Linux 查找mac地址的方法
    Maven 手动添加selenium JAR 包到本地仓库
    Cucumber 行为驱动开发简介
    Cucumber 相关资源
    测试相关资源网站
    openstack之neutron
    Python集合操作
    openstack之nova
    操作系统
    openstack之horizon部署
  • 原文地址:https://www.cnblogs.com/lucienbao/p/Oracle_union_intersect_minus.html
Copyright © 2011-2022 走看看