2
I’m having difficulties using Mysql.
I’ve been asking here already, and I’ve done several tests and progress in the elaboration of a select for a ranking.
I have a "player" table that guards among other elements, the nome_jogador
and pontuacao
. These two Infos are necessary for me to create a query that returns a ranking, being the current player of the app (always in the center unless it is first or last place), above the players (some) with the score immediately higher than the player’s score chosen, and below the players with the score immediately lower than his.
In the query I managed to do this, but if I have a table with 30 players, my query reveals the current score, and the highest and lowest player, ignoring the closest intermediaries, which are the ones I need.
My query current:
select nome_jogador,pontuacao
from jogador
where pontuacao > (select pontuacao from jogador where id_jogador='4') limit 2
union
select nome_jogador,pontuacao
from jogador
where pontuacao < (select pontuacao from jogador where id_jogador='4') limit 2
union
select nome_jogador,pontuacao
from jogador
where id_jogador='4' order by pontuacao desc;
I want to adjust this query to show the others closest to the current player above and below. not the table tips.
I earnestly ask for help