您好,欢迎访问一九零五行业门户网

SQL合并结果集

假设有表(usertb): 1、union(不允许重复) ? 1 2 3 4 5 6 7 select * from dbo.usertb where deptid in ( 1, 3 ) union select * from dbo.usertb where deptid in ( 1, 2 ) 结果: 2、union all(允许重复) ? 1 2 3 4 5 6 7 select * from dbo.usertb wher
假设有表(usertb):
1、union(不允许重复)
?
1
2
3
4
5
6
7
select  *
from    dbo.usertb
where   deptid in ( 1, 3 )
union
select  *
from    dbo.usertb
where   deptid in ( 1, 2 )
结果:
2、union all(允许重复)
?
1
2
3
4
5
6
7
select  *
from    dbo.usertb
where   deptid in ( 1, 3 )
union all
select  *
from    dbo.usertb
where   deptid in ( 1, 2 )
结果:
其它类似信息

推荐信息