title: ERROR 1093 (HY000): You can't specify target table 'a' for update in FROM clause
body: <p>I have this query</p>
  
  <pre><code>UPDATE trh_adminLoginDate SET superseded = true WHERE EXISTS 
   (SELECT * FROM trh_adminLoginDate AS a2 WHERE a2.adminId = a.adminId AND a2.loginDate &gt; a.loginDate AND a2.clientPlatform = a.clientPlatform)
  </code></pre>
  
  <p>and table look like this.</p>
  
  <pre><code>+----------------+--------------+------+-----+---------+----------------+
  | Field          | Type         | Null | Key | Default | Extra          |
  +----------------+--------------+------+-----+---------+----------------+
  | id             | bigint(20)   | NO   | PRI | NULL    | auto_increment |
  | dateCreated    | datetime     | NO   |     | NULL    |                |
  | version        | int(11)      | NO   |     | NULL    |                |
  | dateModified   | datetime     | NO   |     | NULL    |                |
  | adminId        | bigint(20)   | NO   | MUL | NULL    |                |
  | clientPlatform | varchar(255) | YES  |     | NULL    |                |
  | loginDate      | datetime     | YES  |     | NULL    |                |
  | superseded     | tinyint(1)   | NO   |     | NULL    |                |
  +----------------+--------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>When I execute this query I get the below error:</p>
  
  <pre><code>ERROR 1093 (HY000): You can't specify target table 'a' for update in FROM clause
  </code></pre>
  
  <p>I can create temporary table and keep the result of the sub-query and then do the UPDATE. But I don't want to do in this way. Can someone suggest me better way of doing this?</p>