Mysql
 sql >> Database >  >> RDS >> Mysql

Punteggi MySQL - Gradi personali dell'utente:voci duplicate che causano valori errati

prova questo:

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 query avove restituirà il rango per user14950

Questa query elencherà tutti gli utenti e i loro ranghi

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