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