Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top 10 players ranked by score + curent player score

Tags:

mysql

For a server Game... I have table Jewels:

rank,player_id, plscore.

I want to show the top 10 players sorted by their score, high to low, plus the current player score if the current player isn't in the top 10.
It can be my or your score if i/you are not in the top 10 currently. The maximum number of Jewels which can be picked up is 70.

Example(desired):

__________________________________
  rank  |   player_id  |   plscore

   1        zorro007        70
   2        trus            70
   3        edvino          67
   4        snow.boy        65
   5        anida           61 
   6        nadal_raffo     58
   7        syskowitz       43
   8        misterProKill   27
   9        katamadu134     22
   10       ewrgreen89      16
   .             .          .
   .             .          .
   94       CURRENT PLAYER  7
___________________________________

Image: http://postimg.org/image/3x8ktdjct/

like image 380
user2979120 Avatar asked Mar 21 '23 17:03

user2979120


1 Answers

SELECT rank, player_id, plscore 
FROM table_name WHERE rank < 11 
OR player_id = current_player_id 
ORDER BY rank;
like image 186
Marco Frost Avatar answered Apr 01 '23 09:04

Marco Frost