Loading... > 第二种方法(没试过):管理->分类->全选->刷新 1. 找到所有分类(标签同理) ``` SELECT mid FROM typecho_metas AS m WHERE m.type = 'category'; ``` 2. 找到分类关系表,统计文章数 ``` SELECT r.mid, count(cid) FROM typecho_relationships as r WHERE r.mid IN (SELECT mid FROM typecho_metas AS m WHERE m.type='category') GROUP BY r.mid; ``` 3. 提取出分类名称 ``` SELECT r.mid, m.name, count(cid) FROM typecho_relationships as r LEFT JOIN typecho_metas as m ON m.mid=r.mid WHERE r.mid IN (SELECT mid FROM typecho_metas AS m WHERE m.type='category') GROUP BY r.mid; ``` 4. 以上一个查询为基础修改原始表metas ``` UPDATE typecho_metas, (SELECT r.mid AS mid, count(cid) AS COUNT FROM typecho_relationships AS r WHERE r.mid IN (SELECT mid FROM typecho_metas AS m WHERE m.type='category') GROUP BY r.mid) AS tmp SET typecho_metas.COUNT = tmp.COUNT WHERE tmp.mid = typecho_metas.mid; ``` 参考链接:[https://blog.phpgao.com/typecho_delete_category_mistake.html](https://blog.phpgao.com/typecho_delete_category_mistake.html) Last modification:November 21, 2020 © Allow specification reprint Like