SQL将一个表中某一列数据插入到另一张表中

sxh795 2010-10-27 10:53:12
现在我有两张表,表中都有字段im_code和s_code,现在要将一张表中的s_code列导入到另一张表中,其中判断条件是im_code要相等,s_code才能导入进去,要怎么做了,请高手们帮帮忙
...全文
1971 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xczbjwd 2010-10-28
  • 打赏
  • 举报
回复
insert into tb1 select * from tb2 where im_code in (select im_code from tb1)
lyflcear 2010-10-28
  • 打赏
  • 举报
回复
问题说明有问题,建议重新写一下
wuqq410177021 2010-10-27
  • 打赏
  • 举报
回复
insert into tb1 select * from tb2 where im_code in (select im_code from tb1
viqn7qdnt 2010-10-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fredrickhu 的回复:]
SQL code
insert into tb2(s_code) select s_code from tb1 where im_code=tb2.im_code
[/Quote]
up
SQLCenter 2010-10-27
  • 打赏
  • 举报
回复
insert into tb1 select * from tb2 where im_code in (select im_code from tb1)
--小F-- 2010-10-27
  • 打赏
  • 举报
回复
insert into tb2(s_code) select s_code from tb1 where im_code=tb2.im_code

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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