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;

相关文章:

  • 2022-12-23
  • 2021-06-21
  • 2022-02-02
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2019-06-03
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-03-30
  • 2021-07-14
  • 2021-10-18
相关资源
相似解决方案