delete from teacher where id not in (select max(t.id) from teacher t group by t.name)
这条语句是删除姓名重复的,运行是报错,错误如下:
You can't specify target table 'teacher' for update in FROM clause具体什么意思,怎么改才不报错,请指点下,谢谢!
这条语句是删除姓名重复的,运行是报错,错误如下:
You can't specify target table 'teacher' for update in FROM clause具体什么意思,怎么改才不报错,请指点下,谢谢!
delete teacher as a from teacher as a,(select max(t.id) id from teacher t group by t.name) as b where a.id != b.id;
(select max(t.id) id from tt t group by t.name) as b
on a.id != b.id;
DELETE A.* FROM TT A LEFT JOIN (select max(t.id) id from teacher t group by t.name) as b
ON A.ID=B.ID WHERE ISNULL(B.ID)delete A.* from TT A where id not in (select max(t.id) from teacher t group by t.name)
DELETE A.* FROM TT A LEFT JOIN (select max(t.id) id from teacher t group by t.name) as b
ON A.ID=B.ID WHERE ISNULL(B.ID)delete A.* from TT A where id not in (select max(t.id) from teacher t group by t.name)
Don't you think the following is the best reason for your statement?You can't specify target table 'teacher' for update in FROM clause
TT是什么?改成teacher依然报错You can't specify target table 'teacher' for update in FROM clause,还是不清楚为什么?其他的都行!
delete from teacher where id not in (select max(t.id) from teacher t group by t.name)
这种格式,两表删除要用我与yueliangdao0608的格式