The only thing I can think of is doing something like the below query. What I am doing is setting a constant that identifies the mode score, then I wrap that query and order by the mode constant first and the actual score second. Then in your code you know that ModeConst
of 1
is for the mode1_score
and a ModeConst
of 2
is for the mode2_score
.
The mode_score
will be ordered like you want since the constant is ordered first.
SELECT * FROM
(
SELECT 1 AS ModeConst, mode1_score AS ModeScore, name, id, @r := @r + 1 as rank
FROM users, (SELECT @r := 0) r
ORDER BY mode1_score DESC
) a
UNION
SELECT * FROM
(
SELECT 2 AS ModeConst, mode2_score AS ModeScore, name, id, @s := @s + 1 as rank
FROM users, (SELECT @s := 0) s
ORDER BY mode2_score DESC
) b
ORDER BY 1, 2 DESC
Which would produce the following results:
Your code would handle whatever you have for:
//code to output rank here for game mode 1
Then once the first ModeConst
with a value of 2
is found you would start and finish executing whatever you have for:
//code to output rank here for game mode 2