Answer the question
In order to leave comments, you need to log in
How to get MySql user position?
I use the following code to generate a list of the most active users:
SELECT user_id, COUNT(*) as user_commands FROM `log` GROUP BY user_id ORDER BY user_commands DESC
Answer the question
In order to leave comments, you need to log in
In general, you can do this:
SET @number := 0;
SELECT
rating.*
FROM
(
SELECT
(@number := @number + 1) AS number,
user_id,
COUNT(*) AS user_commands
FROM
`log`
GROUP BY
user_id
ORDER BY
user_commands DESC
) AS rating
WHERE
rating.user_id = 2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question