MySQL删除重复记录

网上查了很多关于删mysql中重复记录的方法,很多都是copy且没有经过大脑思考的文章,太浪费时间了,故经过自己测试,给出下面一些语句

DELETE books AS a FROM books AS a,
(
SELECT *
FROM books
GROUP BY book_name
HAVING count(1) >1
order by null
) AS b
WHERE a.book_name = b.book_name AND a.id > b.id;

 

参考文档

http://stackoverflow.com/questions/16035495/you-cant-specify-target-table-for-update-in-from-clause

http://www.cnblogs.com/sunss/archive/2011/01/29/1947469.html

http://www.cnblogs.com/lorgine/archive/2011/01/14/1935447.html