普通网友 2012-06-11 13:20
浏览 29
已采纳

如何获取驻留在一列中的多个结果

I am looking for a query that will return a count of the views column based on a single user's id.

Here is the table's contents:

id |  post_id | user_id | views

1 |      4     |   67    | 4
1 |      56     |   67    | 3
1 |      34     |   67    | 10

I want to get the total of posts views the user have

SELECT *,count(views) from users WHERE user_id = 67

The result have to be 17

  • 写回答

3条回答 默认 最新

  • dongqinta4174 2012-06-11 13:24
    关注
    SELECT user_id, sum(views) FROM users WHERE user_id = 67 GROUP BY user_id
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?