Q: How do I make MySQL also show every users rating and then sort the results using ratings, desc?
This is all used for a gaming ladder. weblGames has the result of every reported game and has info about who won/lost, and what the winner/losers rating became (winner_elo & loser_elo).
Here is a partial screenshot of the table: http://www.ubuntu-pics.de/bild/21059/screenshot_87_RTDZBb.png
Using only this table the current MySQL code displays (thanks to this place) every players name and the number of games he played within the most recent x days, .
I want to keep that info, but also be able to output every players current Elo Point (which equals the winner_elo or loser_elo in his most recently played game.)
Here is the code that I currently have and that displays every player and his/her amount of most recent played games within x days:
SELECT userid, count(*) as cnt
FROM
(
SELECT winner as userid
from webl_games g
where (g.reported_on > now() - interval 4 day
UNION ALL
SELECT loser as userid
from webl_games g
where g.reported_on > now() - interval 4 day
) t
GROUP BY userid
HAVING COUNT(*) >= 3