我正在尝试将 Xoops 帖子转换为 Wordpress。作为其中的一部分,我想获得一个主题的评论数。帖子和回复都在同一个“topic_id”上。如何计算它们并将其发布到新列?
数据库当前状态
topic_id | subject |comment_count|
+________+_____________________+_____________+
1 | welcome |
1 | Re: welcome |
2 | hello world |
2 | Re: hello world |
2 | Re: hello world |
3 | hello friends |
从这里我想将(topic_id 的计数 - 1)作为重播次数(评论计数)。指导我在MYSQL中查询
我想将输出放在同一个表中。(comment_count)
数据库预期输出
| topic_id | subject |comment_count|
+________+_____________________+_____________+
| 1 | welcome | 1
| 1 | Re: welcome | 1
| 2 | hello world | 2
| 2 | Re: hello world | 2
| 2 | Re: hello world | 2
| 3 | hello friends | 0