Code Bye

MySql错误 You can’t specify target table for update in FROM clause

在Mysql下执行删除重复记录的SQL语句:
delete from blur_article where id not in(select min(id) from blur_article group by   title)执行后报错!
#1093 - You can't specify target table 'blur_article' for update in FROM clause 
在Mysql下执行查询:
select * from   blur_article    where   id   not   in(select   min(id)   from  blur_article    group   by   title)
执行语句显示成功!上面的delete却不能执行,此时的去重复操作在mysql中不能这么用。 (等待mysql升级后也许可以)
错误提示就是说,不能先select出同一表中的某些值,再update这个表(在同一语句中) 

可以尝试以下替换方案去重复: 
create table tmp as select min(id) as col1 from blur_article group by title;
delete from blur_article where id not in (select col1 from tmp); 
drop table tmp;

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明MySql错误 You can’t specify target table for update in FROM clause