交集:Intersect
select customer_id,key_,value_ from t_customer_contact_bak ccc
intersect
select customer_id,key_,value_ from t_customer_contact ccc
差集:MINUS (SqlServer中使用except关键字)
select customer_id,key_,value_ from t_customer_contact_bak ccc
MINUS
select customer_id,key_,value_ from t_customer_contact ccc
并集:Union
--去重
select customer_id,key_,value_ from t_customer_contact_bak ccc
Union
select customer_id,key_,value_ from t_customer_contact ccc
select customer_id,key_,value_ from t_customer_contact_bak ccc
Union All
select customer_id,key_,value_ from t_customer_contact ccc
2019年第一篇博文,好的开始,加油!
本文深入探讨了SQL中的集合操作,包括交集(Intersect)、差集(MINUS/except)及并集(Union),并提供了具体的SQL语句示例,帮助读者理解如何在实际数据库操作中应用这些集合运算。
2123

被折叠的 条评论
为什么被折叠?



