mysql删除重复数据
转载自:https://blog.csdn.net/n950814abc/article/details/82284838
delete
FROM
tbl_orc_record
WHERE
( worker_name, id_card, bank_card ) IN (
SELECT
t.worker_name,
t.id_card,
t.bank_card
FROM
( SELECT worker_name, id_card, bank_card FROM tbl_orc_record GROUP BY worker_name, id_card, bank_card HAVING count( 1 ) > 1 ) t
)
AND id NOT IN (
SELECT
dt.id
FROM
( SELECT max(id) AS id FROM tbl_orc_record GROUP BY worker_name, id_card, bank_card HAVING count( 1 ) > 1 ) dt
)
and three_element_state = -1