日期:2014-05-18  浏览次数:20475 次

怎样将多个字段一样的表合成一张表?谢谢!
怎样将多个字段一样的表合成一张表?
Sql语句应该怎么写啊?

------解决方案--------------------
select * from 表1
union all
select * from 表2
union all
select * from 表N
------解决方案--------------------
--显示
select * from tb1
union all
select * from tb2
union all
....
select * from tbn

select * into newtb
(
select * from tb1
union all
select * from tb2
union all
....
select * from tbn
) t

------解决方案--------------------
create view v_name as

select * from 表1
union all
select * from 表2
union all
select * from 表N

------解决方案--------------------
select * into newtb
(
select 列表1,列表2... from tb1
union all
select 列表1,列表2... from tb2
union all
....
select 列表1,列表2... from tbn
) t
------解决方案--------------------
select * into 总表 from(
select * from 表1
union all
select * from 表2
union all
select * from 表N)t

select * from 总表

--union all,将两个结果连接在一起,详细看联机帮助.
------解决方案--------------------
create table newtable(
..
..
)

insert into newtable
select * from 表1
union all
select * from 表2
union all
select * from 表N

这样也可以,另一种方法。
楼上的更好一些,省去了创建表的步骤
------解决方案--------------------
报错:“t”附近有语法错误!
-------------------------------
少一个from

SELECT *
INTO new from
(SELECT *
FROM [20070327hy1]
.....