SQLServer数据集合的交、并、差集运算
发布时间:2020-12-12 15:34:33 所属栏目:MsSql教程 来源:网络整理
导读:????? SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。 他们的对应关系可以参考下面图示 ? ?????? 相关测试实例如下: ? use tempdb go if ( object_id ( 't1' ) is not null ) drop table t1 if ( object_id ( 't2' ) is
????? SQLServer2005通过intersect,union,except和三个关键字对应交、并、差三种集合运算。 他们的对应关系可以参考下面图示 ? ?????? 相关测试实例如下: ? use tempdbgo 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*/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 关于云计算的一点看法(从Dell的云存储说起)
- sqlserver2005 表结构 导入到 oracle 转载
- sql-server-2008-r2 – 错误:注意:无法通过电子邮件通知“
- CentOS 6.2 下升级安装为MySQL 5.5的方法
- SQL Server 数据操作类代码
- sql-server-2005 – 查询以查找其中包含日期列的所有表
- sql-server – 如何在Sql中创建“月”列?
- sql server2012附加数据库问题解决方法
- 用SQL2005的row_number()自定义分页存储过程
- sql-server – SQL Server – 由于’ARITHABORT’而INSERT失