Show the best player depend of Medals achieved Mysql/php -
i have medals table :
have 3 rows : id of medals , type of medals (0 = gold , 1 = silver , 2 = bronze) , playerid
so have example :
id | type | playerid --- ---- --------- 1 0 1 2 2 1 3 0 1 4 1 2 5 1 2 6 0 3 *so that's mean :
the player 1 has 2 gold medals , 1 bronze
the player 1 has 2 silver medals
the player 3 has 1 bronze medal
so cant show them in order of best until last means :
player 1 because have player 1 has 2 gold medals more
player 3 has 1 medal gold one
player 2 last 1 has 2 medals silver medals
so hope understand don't want order them sum of medals have category of medals have
example : if player x has 2 gold medals , 1 silver , 0 bronze , player y has 1 gold , 10 silver , 5 bronze , player x should first because hase gold ones ! .
i hope gave right explaining of problem .
witing suggestions of how make mysql query , php.
regards.
in mysql, it's simple order counts of categories;
select playerid medals group playerid order sum(type=0) desc, sum(type=1) desc, sum(type=2) desc or, info @ once;
select playerid, sum(type=0) gold, sum(type=1) silver, sum(type=2) bronze medals group playerid order gold desc, silver desc, bronze desc
Comments
Post a Comment