我是靠谱客的博主 震动菠萝,最近开发中收集的这篇文章主要介绍SQLServer 数据集合的交、并、差集运算,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

他们的对应关系可以参考下面图示相关测试实例如下:
 
相关测试实例如下:

复制代码 代码如下:

use tempdb
go
if (object_id ('t1' ) is not null ) drop table t1
if (object_id ('t2' ) is not null ) drop table t2
go
create table t1 (a int )
insert into t1 select 1 union select 2 union select 3
create table t2 (a int )
insert into t2 select 3 union select 4 union select 5
go
select * from t1 union select * from t2
go
/* 求表并集
1
2
3
4
5*/
select * from t1 union all select * from t2
go
/*求表并集不过滤重复
1
2
3
3
4
5*/
select * from t1 except select * from t2
go
/*求t1对t2的差集
1
2*/
select * from t1 intersect select * from t2
go
/*求t1对t2的交集
3*/

最后

以上就是震动菠萝为你收集整理的SQLServer 数据集合的交、并、差集运算的全部内容,希望文章能够帮你解决SQLServer 数据集合的交、并、差集运算所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(103)

评论列表共有 0 条评论

立即
投稿
返回
顶部