View Full Version : updating database
12-12-2011, 03:13 AM
So i have a database with player and their rank. So when rank(5) player challenge rank(3) player and rank(5) beats rank(3). Rank(5) gets rank(3) ranking. What is the best way to do this without doing like 6 or 7 queries.
12-12-2011, 06:12 AM
UPDATE players AS p1, players AS p2
SET p1.rank = p2.rank
WHERE p1.rank < p2.rank
AND p1.playerid = $winnerid
AND p2.playerid = $loserid
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.