hypothetic tables
user_id | hits
Can I get MySQL to return the total hits of a Select query? I know i could add them together with php or similar, just wondering if there is a pure MySQL way?
hypothetic tables
user_id | hits
Can I get MySQL to return the total hits of a Select query? I know i could add them together with php or similar, just wondering if there is a pure MySQL way?
Total hits per user
SELECT userId, Sum(Hits)
FROM Table
GROUP by userId
OR
Total hits
SELECT Sum(Hits)
FROM Table
Depending on the specific SQL query you're using you could either SUM a column or potentially use the 'WITH ROLLUP' GROUP modifier if you require a query-wide total.