-1

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.

closed as unclear what you're asking by Taryn, Mark Storey-Smith, RolandoMySQLDBA, Max Vernon, Paul White Nov 20 '14 at 3:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Why not just ORDER BY xp then add the rank number in the application? – Neghtasro Nov 19 '14 at 14:27
  • I answered a very similar question here: dba.stackexchange.com/questions/73168/… but I warned that that wasn't MySQL's way of doing things. – jynus Nov 19 '14 at 15:46
1

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

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

  • that code seemed to do the trick – marxizmmarxizm Nov 19 '14 at 23:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.