#任务背景
在表内存在着测试数据,他们都是重复的,要用mysql将其删除,一条都不留。
#系统阻止代码
delete
from A where ID
in ( select ID from A
group by name, ID
having count(ID)>1)
* 报错:You can't specify target table 'student' for update in FROM clause
* 报错解读:不能在进行查询操作同一张表的同时进行修改和更新操作
* 原因:由于数据库系统安全问题导致,数据库拒绝此类危险的操作,防止数据被清空
#绕过系统删除法
delete
from A
where ID
in(select s.ID
from (select ID
from A
group by ID
having count(ID)>1) as s);