1、差集( except )

select a from t_a

except

select a from t_b

 

-- 也可写作:

select a from t_a where a not in (select a from t_b)

 

-- 多个字段时:

select a,b from t_a

except

select a,b from t_b

 

-- 多字段的查集也可写成:

select a,b from t_a where (a,b) not in (select a,b from t_b)

 

2、交集( intersect )

select a from t_a

intersect

select a from t_b

 

-- 也可写作:

   select a from t_a where a in (select a from t_b)

 

3、并集( union )

select a from t_a

union distinct

select a from t_b

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2021-07-28
  • 2021-10-31
  • 2021-09-27
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2021-10-23
  • 2021-11-06
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案