I am trying to convert Xoops posts to WordPress. As part of that, I want to get comment count for a topic. Post and replies are on same “topic_id”. How to count them and post it in to new column?
DB current status
topic_id | subject |comment_count|
+________+_____________________+_____________+
1 | welcome |
1 | Re: welcome |
2 | hello world |
2 | Re: hello world |
2 | Re: hello world |
3 | hello friends |
from here I want to take the (count of topic_id – 1) as the number of replays (comment count). Guide me to query in MYSQL
I want to place the output in the same table. (comment_count)
DB expected output
| 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
1 Answer