《MySQL教程Mysql入门》要点:
本文介绍了MySQL教程Mysql入门,希望对您有用。如果有疑问,可以联系我们。
导读:[Err] 1093 - You can't specify target table 'user' for update in FROM clause报错的sql如下:delete from `...
[Err] 1093 - You can't specify target table 'user' for update in FROM clause
报错的sql如下:
delete from `user` where id not in (select min(id) as id from `user` group by name );
报错的原因是:不能先select出同一表中的某些值,再update这个表(在同一语句中).
改成下面这样就好了(将查出的数据再通过中间表查一遍):
delete from `user` where id not in (
select id from(
select min(id) as id from `user` group by name
) id
);
转载请注明本页网址:
http://www.vephp.com/jiaocheng/5597.html