我正在尝试运行这个:
$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());
但它会导致 MySQL 错误:#1093 - You can't specify target table 'table1' for update in FROM clause
.
搜索此错误后,似乎In MySQL, you can't modify the same table which you use in the SELECT part.
.
如何更改该查询以使其正常工作?
非常感谢提前