You can‘t specify target table ‘表名‘ for update in FROM clause

You can‘t specify target table ‘表名‘ for update in FROM clause

mysql执行删除语句时提示You can't specify target table '表名' for update in FROM clause,意思是说不能依据某字段值做判断再来更新某字段的值,修改sql语句:

DELETE from ntm_third_user where id in (
SELECT a.id from
(SELECT t.id FROM `ntm_third_user` t LEFT JOIN t_s_base_user u on t.user_id = u.id
where u.id is null) a
),成功删除。

或者

delete a from ntm_third_user a left join t_s_base_user b on a.user_id = b.id where b.id is null