mysql一条sql完成统计帖子下面有多少条回复

mysql一条sql完成统计帖子下面有多少条回复

SELECT a.*,(select count(*) from theme as b where b.parent_id=a.id) as tiezi_count FROM `theme` as a WHERE a.id>0 

在需要取的字段中,写mysql的子查询进行统计。

posted on 2020-12-11 13:55  鱼塘总裁  阅读(176)  评论(0编辑  收藏  举报