SQLServer数据集合的交、并、差集运算
2011-05-09 10:53
204 查看
SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。
他们的对应关系可以参考下面图示
相关测试实例如下:
usetempdb
go
if (object_id ('t1' ) isnotnull ) droptablet1
if (object_id ('t2' ) isnotnull ) droptablet2
go
createtablet1 (aint )
insertintot1select1unionselect2unionselect3
createtablet2 (aint )
insertintot2select3unionselect4unionselect5
go
select*fromt1unionselect*fromt2
go
/* 求表并集
1
2
3
4
5*/
select*fromt1unionall select*fromt2
go
/*求表并集不过滤重复
1
2
3
3
4
5*/
select*fromt1exceptselect*fromt2
go
/*求t1对t2的差集
1
2*/
select*fromt1intersectselect*fromt2
go
/*求t1对t2的交集
3*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/09/07/4527863.aspx
他们的对应关系可以参考下面图示
相关测试实例如下:
usetempdb
go
if (object_id ('t1' ) isnotnull ) droptablet1
if (object_id ('t2' ) isnotnull ) droptablet2
go
createtablet1 (aint )
insertintot1select1unionselect2unionselect3
createtablet2 (aint )
insertintot2select3unionselect4unionselect5
go
select*fromt1unionselect*fromt2
go
/* 求表并集
1
2
3
4
5*/
select*fromt1unionall select*fromt2
go
/*求表并集不过滤重复
1
2
3
3
4
5*/
select*fromt1exceptselect*fromt2
go
/*求t1对t2的差集
1
2*/
select*fromt1intersectselect*fromt2
go
/*求t1对t2的交集
3*/
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/09/07/4527863.aspx
相关文章推荐
- SQLServer数据集合的交、并、差集运算
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLServer数据集合的交、并、差集运算
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLServer数据集合的交、并、差集运算
- SQLSERVER数据集合的交、并、差集运算(intersect,union,except)
- SQLServer数据集合的交、并、差集运算
- sqlserver三种数据集合运算
- SQLServer数据集合的交、并、差三种集合运算
- 重载运算符“+”、“*”、“-”实现集合的并集、交集、差集运算
- 重载运算符“+”、“*”、“-”实现集合的并集、交集、差集运算
- IOS开发中集合操作 处理数据的 交集 并集 差集
- SQL集合运算:差集、交集、并集
- 数据结构笔记(一)线性表的顺序表示和基本操作及其顺序表实现的集合运算(A-B)U(B-A)实例
- SQL语句(十六)实现集合运算、对数据修改、数据表复制
- SQL集合运算:差集、交集、并集
- SQL集合运算:差集、交集、并集