COUNT / GROUP BY with active record?

后端 未结 5 2180
既然无缘
既然无缘 2020-12-01 12:02

I have a table with the following info:

id  |  user_id  |  points
--------------------------
1   |  12       |  48
2   |  15       |  36
3   |  18       |  2         


        
5条回答
  •  误落风尘
    2020-12-01 13:03

    I think you should count the results with FOUND_ROWS() and SQL_CALC_FOUND_ROWS. You'll need two queries: select, group_by, etc. You'll add a plus select: SQL_CALC_FOUND_ROWS user_id. After this query run a query: SELECT FOUND_ROWS(). This will return the desired number.

提交回复
热议问题