SQLServer数据集合的交、并、差集运算
2010-03-03 01:09
351 查看
SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。
他们的对应关系可以参考下面图示
相关测试实例如下:
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*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/09/07/4527863.aspx
他们的对应关系可以参考下面图示
相关测试实例如下:
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*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/09/07/4527863.aspx
相关文章推荐
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLServer数据集合的交、并、差集运算
- sqlserver三种数据集合运算
- SQLServer数据集合的交、并、差三种集合运算
- ORACLE 数据查询集合即:查询结果的集合操作 并集 交集 差集
- 重载运算符“+”、“*”、“-”实现集合的并集、交集、差集运算
- 去掉集合里相同数据的对象与求两个对象集合的差集的方法
- python set集合运算(交集,并集,差集,对称差集)
- sqlserver中数据集合的交、差、并
- 构建一个类,对集合进行运算,包括求集合的交集,并集和差集。
- 数据结构笔记(一)线性表的顺序表示和基本操作及其顺序表实现的集合运算(A-B)U(B-A)实例
- 数据结构:求集合差集(c/c++)