title: MySQL UPDATE query where id is highest AND field is equal to variable
body: <p>I'm trying to construct a MySQL query that will UPDATE a row in my table WHERE the id is highest AND a field called idSession is equal to 65. It looks like this:</p>
  
  <pre><code>UPDATE `History` 
  SET `state` = 0 
  WHERE `id` = (SELECT MAX(id) FROM `History` WHERE `idSession` = 65);
  </code></pre>
  
  <p>And I'm getting the error message: </p>
  
  <blockquote>
    <p>"Error Code: 1093. You can't specify target table 'History' for update
    in FROM clause".</p>
  </blockquote>
  
  <p>Anyone know what's wrong with my syntax?</p>