如何把Select查询得到的单列记录集插入一个表中制定的一列?(类型相同)
比如我有如下记录集:
select top 40 id from tbl group by id order by count(*) desc
如何把这个结果直接插入到表bbb的myid列?
表bbb还有其他列都是可以为空的列和自增列。
------解决方案--------------------insert into bbb(myid) select top 40 id from tbl group by id order by count(*) desc
------解决方案--------------------insert bbb(myid)
select top 40 id from tbl group by id order by count(*) desc
------解决方案--------------------insert into bbb select ' ', ' ',a.* from(select top 40 id from tbl group by id order by count(*) desc)a
字段对应好
------解决方案--------------------INSERT INTObbb(myid)
SELECT top 40 [id]
FROM tbl
GROUP BY [id]
ORDER BY count(*) DESC