title: mysql update multiple records of multiple tables using one statement based on condition
body: <p>I have a mysql table for keeping record of two person competitions like this:</p>
  
  <pre><code>- gameid
  - id1 // id of player 1
  - id2 // id of player 2
  - score1 // score of player 1
  - score2 // score of player 2
  - state // state of the games is initially 0, then the score updates are made and in order to prevent further updates the state must be updated to 1
  </code></pre>
  
  <p>I need to check the records and update another table "users" based on the scores. ex:
  if <strong>score1 > score2</strong> I need to update 3 things:</p>
  
  <pre><code>1- the state of the game // from 0 to 1
  2- in table "users" add 1 point to the column score for the user with userid = id1
  2- in table "users" subtract 1 point from the column score for the user with userid = id2
  </code></pre>
  
  <p>So far I am able to update 1 and 2 but I need all the 3 updates in one command:</p>
  
  <pre><code>UPDATE dbo.games AS GA , dbo.users AS US 
  SET GA.state = 1, US.score = US.score + 1
  WHERE US.id = GA.id1 AND GA.state = 0 and GA.score1 &gt; GA.score2
  </code></pre>
  
  <p>I can separate the <strong>+1</strong> and <strong>-1</strong> commands, it will work fine. But when the command is run, both users' scores should be updated. Can anyone help?</p>