title: How can I update a table in which I make a SELECT query? (Error #1093)
body: <p>I am trying to run this:</p>
  
  <pre><code>$stmt=$cxn-&gt;prepare("UPDATE table1 SET used='1' WHERE prim_id != 
       (SELECT MAX(prim_id) FROM table1 WHERE email='email12345@gmail.com')");
  $stmt-&gt;execute(array());
  </code></pre>
  
  <p>But it results in a MySQL error: <code>#1093 - You can't specify target table 'table1' for update in FROM clause</code>.</p>
  
  <p>After searching this error, it seems that <code>In MySQL, you can't modify the same table which you use in the SELECT part.</code>.</p>
  
  <p>How can I change that query to make it work?</p>
  
  <p>Thanks a lot in advance</p>