27,579
社区成员
发帖
与我相关
我的任务
分享
if object_id('[ta]') is not null drop table [ta]
go
create table [ta]([id] int,[name] varchar(1))
insert [ta]
select 1,'a' union all
select 2,'b' union all
select 3,'a' union all
select 4,'c'
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([id] int,[name] varchar(1))
insert [tb]
select 1,'a' union all
select 2,'a' union all
select 3,'b' union all
select 4,'c'
select name from ta
union
select name from tb
/**
name
----
a
b
c
(所影响的行数为 3 行)
**/
select name from ta
union all
select name from tb
/**
name
----
a
b
a
c
a
a
b
c
(所影响的行数为 8 行)
**/
select col1 from table
union
select col1 from table1