Home > Database > Mysql Tutorial > SQL合并结果集

SQL合并结果集

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:54:06
Original
1519 people have browsed it

假设有表(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):

SQL合并结果集   三联

  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 )

  结果:

SQL合并结果集

  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 )

  结果:

SQL合并结果集

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template