如何把一个表中的记录插入到另外一个表中

tianhuo_soft 2008-01-05 11:30:36
我以前这样做过
insert into table1
SELECT from table2
where tiaojian='1'
这样就能把table2中所有tiaojian字段中是1的记录插入到table1中

我现在想把这样

insert into table1('remark')values
SELECT distinct remark from table2
where remark in('A,'B','C') --ABC会有重复的所以加了 distinct
就是把table2中满足条件的记录中的一个字段插入table1中的某个字段中
...全文
68 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzy_love_sly 2008-01-05
  • 打赏
  • 举报
回复
:)
-狙击手- 2008-01-05
  • 打赏
  • 举报
回复
declare @ta table(id int, timestamp)
declare @tb table(id int, timestamp)

insert @ta(id) select distinct id from @tb






insert into table1(remark)
SELECT remark from table2
where remark in('A,'B','C')

simonhehe 2008-01-05
  • 打赏
  • 举报
回复
哈哈,图省事,结果楼主还暗藏杀招,寒..
simonhehe 2008-01-05
  • 打赏
  • 举报
回复


insert into table1(remark)
SELECT remark from table2
where remark in('A','B','C')
group remark

-- n_n 晕了
wzy_love_sly 2008-01-05
  • 打赏
  • 举报
回复
ls颜色都变了
simonhehe 2008-01-05
  • 打赏
  • 举报
回复

insert into table1('remark')
SELECT remark from table2
where remark in('A','B','C')
group remark

simonhehe 2008-01-05
  • 打赏
  • 举报
回复

insert into table1('remark')
SELECT remark from table2
where remark in('A,'B','C')
group remark

34,575

社区成员

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

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