楼上正解,具体如下 Select distinct [A] from (SELECT [A] FROM [ypdebt] union SELECT [A] FROM [spdebt]) #temp1
select * into new from (select * from ypdebt union select * from spdebt) #temp1
select [A] FROM [ypdebt] union SELECT [A] FROM [spdebt] 在默认情况下,union运算符将从结果集中删除重复的行,如果使用ALL关键字,那么结果中将包含所有行而不删除重复行
SELECT A FROM 表1 UNION SELECT A FROM 表2UNION 会自动去除重复的
select A from 表1 union select B from 表2
1 [code=MSIL]select distinct 字段 from ( select A from 表1 union all select B from 表2 )[/code]2 [code=MSIL]select * into #t from A where 1=1 insert into #t select from A insert into #t select from Bselect distinct 字段 from #t[/code]
Select distinct [A] from (SELECT [A] FROM [ypdebt] union SELECT [A] FROM [spdebt]) #temp1
union
SELECT [A] FROM [spdebt]
在默认情况下,union运算符将从结果集中删除重复的行,如果使用ALL关键字,那么结果中将包含所有行而不删除重复行
UNION
SELECT A FROM 表2UNION 会自动去除重复的
select A from 表1
union
select B from 表2
[code=MSIL]select distinct 字段 from
(
select A from 表1
union all
select B from 表2
)[/code]2
[code=MSIL]select * into #t from A where 1=1
insert into #t select from A
insert into #t select from Bselect distinct 字段 from #t[/code]