您的位置:首页 > 其它

You can't specify target table 'Person' for update in FROM clause

2017-04-20 15:03 411 查看
mysql
中调用下面的语句提示该错误

delete from Person where id in (
select t1.id from Person t1, Person t2 where t1.email = t2.email and t1.id > t2.id
);


In MySQL, you can’t modify the same table which you use in the SELECT part.

解决方法:

建立一张临时的中间表

delete from Person where id in (
select id from(
select t1.id as id from Person t1, Person t2 where t1.email = t2.email and t1.id > t2.id
) as tmp
);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐