时间:2021-07-01 10:21:17 帮助过:17人阅读
删除重复记录
DELETE FROM event_log WHERE `code`=‘code1‘ AND identity IN ( SELECT identity from ( SELECT identity FROM event_log WHERE code=‘code1‘ GROUP BY identity HAVING count(identity) > 1 ) a ) AND id NOT IN ( SELECT keepId FROM ( SELECT min(id) keepId FROM event_log WHERE code=‘code1‘ GROUP BY identity HAVING count(identity) > 1 ) b )
其中 a 和 b 两个中间表的作用是, 避免执行时出现 You can‘t specify target table ‘xxxxx‘ for update in FROM clause 错误
MySQL中删除多余的重复记录
标签:use table not eve 执行 xxxx count 检查 作用