怎么将一个表的一列数据插入到另一表中!!!

qq98504288 2012-02-16 05:39:09

science 表
name count other
a1 5 aa1
a2 6 aa2


super 表
name sey
b1 5
b2 6



如何将 super表的那么字段所有值插入至science表。

插入后结果
science 表
name count other
a1 5 aa1
a2 6 aa2
b1
b2
...全文
107 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jmx123456789 2012-02-17
  • 打赏
  • 举报
回复

insert into science(name,coun,other)
select name,coun,other from science
叶子 2012-02-16
  • 打赏
  • 举报
回复

declare @science table
(name varchar(2),[count] int,other varchar(3))
insert into @science
select 'a1',5,'aa1' union all
select 'a2',6,'aa2'

declare @super table (name varchar(2),sey int)
insert into @super
select 'b1',5 union all
select 'b2',6

insert into @science(name) select name from @super

select * from @science
/*
name count other
---- ----------- -----
a1 5 aa1
a2 6 aa2
b1 NULL NULL
b2 NULL NULL
*/

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧