mysql 临时表联合修改统计数据
文章表:blog_article
文章分类表:blog_category
现在统计出文章分类下的文章数然后修改文章分类表的文章数字段的值:
思路:建一临时表得出统计数据,然后用联合更新
create table tmptable
SELECT category_id,count(1) as count1 from blog_article group by category_id;
update blog_category bc inner join tmptable bb on bc.id = bb.category_id set bc.article_num =bb.count1 ;
drop table tmptable;

浙公网安备 33010602011771号