mardi 24 mars 2015

PHP/MySQL Rank by multiple columns

I'm developing a game that scores players in 2 different ways, A, B. In this game I have a ranking page that shows what position you are in ranking A, B and A+B as well as a list of players ordered by A+B.


What would be the most efficient way to retrieve your rank in these different scoring situations as well as the nearby users for rank A+B (to display on the list)?


I assume I would have to do a pass over every user at least once. Should I attempt this with multiple left joins and subselects and count users with score A/B/A+B greater than yours, or just query for the whole user+score list and calculate the ranks with a PHP function?





Aucun commentaire:

Enregistrer un commentaire