How can I count the number of posts?

后端 未结 3 1385
太阳男子
太阳男子 2021-01-29 03:37

Here is my table structure:

-- reputations
+----+-------------+---------+-------+------------+------------+
| id | post_id     | user_id | score | reputation | d         


        
3条回答
  •  隐瞒了意图╮
    2021-01-29 04:27

    Did you try adding the post id to the query?

    I added count(r.post_id) as post_num in your select statement and it gave the expected results.

    To remove duplicates, use distinct. Do you want the count with respect to tag table? Try

    1. COUNT(distinct pt.post_id) AS post_count; or
    2. COUNT(distinct r.post_id) AS post_count

提交回复
热议问题