SQL语句·查询某id 发布的数量并进行统计保存到字段
发布网友
发布时间:2022-04-11 00:19
我来回答
共2个回答
热心网友
时间:2022-04-11 01:48
insert into info(id,count_comment)
select contid,count(*) as Nums from comment group by contid
是不是就这样,OK,请采纳
热心网友
时间:2022-04-11 03:06
select contid
,sums = count(1)
into #temp
from comment
group by contid
update info
set count_commen=b.sums
from info a
join #temp b
on a.id = b.contid