Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Post counter


I have to make forum endpoint where I need to count posts of each thred and return one thred with highest number of posts. In my database table I have post table with id of thred (id of threed where post belong). How to count posts of each thred and then return thred with highest number of posts.



You can make a group by query on posts table. Counting, while grouping by thread_id. Also you can add order by postsCounter DESC and LIMIT 1 to get only thread with highest posts. Or LIMIT 10 for top 10 most commented threads e.t.c...


Thanks friend, I id it with grouping results and order it with right way .. thx again

edited Jul '16

Glad you solved it @Armin, can you perhaps paste your code/query here in case some other forum member needs it in future?