Mysql – Get a teams Rank based their xp


Table is called teams, need to get the following columns… name, wins, losses, percentage, level, xp WHERE console = 3 AND game = 23 AND laddertype = 1 I'm in need of a Rank column to be included with the dataset.

Best Answer

$result = mysql_query("SET @Rank := 0");

$result = mysql_query("SELECT *, @Rank := @Rank + 1 AS Rank FROM teams ORDER BY xp DESC, created ASC");