UPDATE user SET pwd='123' WHERE id in (
SELECT id from user WHERE username = 'zx'
);
报错[Err] 1093 - You can't specify target table 'user' for update in FROM clause
我们可以写内连接达到同样的效果 :
UPDATE USER a
INNER JOIN USER b ON b.username = 'zx'
AND a.id = b.id
SET a.pwd = 3