问答详情
源自:4-1 MySQL-利用主键删除重复数据

我在sql 2008写的代码,出错了要怎么改?

delete a from tb1 a join (select name,count(*) from tb1 group by name having COUNT (*)>1) b on a.name=b.name where a.ID<b.ID;


提问者:祁望 2016-05-09 14:14

个回答

  • 诡异之心0908
    2016-07-18 22:09:42
    已采纳

    给聚合函数count(*)取个别名就可以了, delete ……join (……count(*) as num  from ……)……

  • 祁望
    2016-05-09 14:15:51

    http://img.mukewang.com/57302b000001289a03610118.jpg...