sql 来自http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql s

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 来自http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql s相关的知识,希望对你有一定的参考价值。

# 1) If you want to keep the row with the lowest id value:

DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name
# 2) If you want to keep the row with the highest id value:

DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name

以上是关于sql 来自http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql s的主要内容,如果未能解决你的问题,请参考以下文章