zoukankan      html  css  js  c++  java
  • PostgreSQL(EXCEPT,INTERSECT)

    except 可以查看表一对表二不一样的数据,有点像是对表一进行表一表二交集的反集的交集,好绕;

    intersect 可以查看表一和表二一样的数据,求交集;

    select t1.name,t1.age,t1.country from table_1 t1

    except

    select t2.name,t2.age,t2.country from table_2 t2 order by name,age;

    可以对两表使用where条件;

    可以将except结果创建成一张新的表:

    create table table_3 as (

    select t1.name,t1.age,t1.country from table_1 t1

    except

    select t2.name,t2.age,t2.country from table_2 t2 order by name,age;

    );

    可以将except结果插入另一张表:

    insert into table_2(name,age,country)

    select t1.name,t1.age,t1.country from table_1 t1

    except

    select t2.name,t2.age,t2.country from table_2 t2 order by name,age;

    --- --- LilyLee --- ---
  • 相关阅读:
    poj3411
    2241 排序二叉树
    1004 四子连棋
    Poj1482
    poj2046
    Poj3087
    poj3414
    php使用flock堵塞写入文件和非堵塞写入文件
    HTML样式以及使用
    高效程序猿的狂暴之路
  • 原文地址:https://www.cnblogs.com/apro-abra/p/4943130.html
Copyright © 2011-2022 走看看