码迷,mamicode.com
首页 > 数据库 > 详细

数据库去重

时间:2020-07-14 16:31:08      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:limit   where   bsp   not   set   value   count   group   查询   

查询
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 )

数据库去重

标签:limit   where   bsp   not   set   value   count   group   查询   

原文地址:https://www.cnblogs.com/xiaowangba9494/p/13299658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!