Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySQL Highscores - Rangs personnels de l'utilisateur :entrées en double entraînant des valeurs incorrectes

essayez ceci :

SET @rank = 0;
SELECT rank FROM (
    SELECT @rank:[email protected] + 1 AS rank, uid FROM playerstats ORDER BY overall DESC, 
    overallxp  DESC
) as tmp WHERE uid = 14950

la requête avove renverra le rang pour user14950

Cette requête listera tous les utilisateurs et leurs rangs

SET @rank=0;
SELECT rank, uid, overall, overallxp FROM (
SELECT @rank:[email protected] + 1 AS rank, uid, overall, overallxp FROM playerstats ORDER BY overall DESC, overallxp DESC
) as tmp