首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

怎么用SQL语句将数据库表合并

2012-01-19 
如何用SQL语句将数据库表合并?有三个数据库表,字段名称大同小异现在要将三个数据库表中的数据转移到新建的

如何用SQL语句将数据库表合并?
有三个数据库表,字段名称大同小异
现在要将三个数据库表中的数据转移到新建的表中
这个新建的表中仅仅多个一个字段
用Sql语句怎么实现?

[解决办法]
insert into newtable
select * from
(
select * from table1
union all
select * from table2
union all
select * from table3
)
a
[解决办法]
select * into newtablename
from (
select col1 ,col2...coln from table1
union all
select col1 ,col2...coln from table2
union all
select col1 ,col2...coln from table3
)

热点排行