数据库去重
Posted xiaowangba9494
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库去重相关的知识,希望对你有一定的参考价值。
查询
SELECT
*
FROM
table A
WHERE
( A.the_date, A.exponent_code, A.exponent_value ) IN ( SELECT the_date, exponent_code, exponent_value FROM table GROUP BY the_date, exponent_code, exponent_value HAVING COUNT ( * ) > 1 )
AND A.ID NOT IN ( SELECT MIN ( ID ) FROM table GROUP BY the_date, exponent_code, exponent_value HAVING COUNT ( * ) > 1 )
LIMIT 10000 OFFSET 1
删除
DELETE
FROM
table A
WHERE
( A.the_date, A.exponent_code, A.exponent_value ) IN ( SELECT the_date, exponent_code, exponent_value FROM table GROUP BY the_date, exponent_code, exponent_value HAVING COUNT ( * ) > 1 )
AND A.ID NOT IN ( SELECT MIN ( ID ) FROM table GROUP BY the_date, exponent_code, exponent_value HAVING COUNT ( * ) > 1 )
以上是关于数据库去重的主要内容,如果未能解决你的问题,请参考以下文章