I\'m trying to get my head around a query and I just can\'t figure it out. I would appreciate if someone give me a pointer. As a simple example of what I\'m trying to achiev
This creates an inline update statement that will rank your players incrementing by the variable @rc. I've used it many times in very similar cases, it works well and keeps it all on the DB side.
SET @rc = 0;
UPDATE players JOIN (SELECT @rc := @rc + 1 AS rank, id FROM players ORDER BY rank DESC)
AS order USING(id) SET players.rank = order.rank;
id is assumed to be the primary key for your players table.