Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    updating database

    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.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,901
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Code:
    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
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •