mysql 数据去重复

DELETE

FROM  `portrait_tc_call_record`

WHERE

detailsId IN (

SELECT cr.detailsId

FROM ( SELECT detailsId

FROM `portrait_tc_call_record`

GROUP BY detailsId,party_id,bill_Month

HAVING COUNT(detailsId) > 1

) cr

)

AND id NOT IN (

SELECT tc.id

FROM ( SELECT MIN(id) id

FROM `portrait_tc_call_record`

GROUP BY detailsId,party_id,bill_Month

HAVING COUNT(detailsId) > 1

) tc

)

你可能感兴趣的:(mysql 数据去重复)