Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从 mysql 数据库中删除重复记录。使用以下命令,它将删除所有重复项并保留一行。在我的数据库中有 300,000 条记录,我预计大约有 100,000 行是重复的。
重复项需要通过以下命令删除,但问题是,我在 9 小时后的晚上给出了命令,它仍在运行。
DELETE n1 FROM tableA n1,tableA n2 WHERE n1.title= n2.title AND n1.id > n2.id
怎么了?谁能解释一下?
试:
select * from tableA as n1 join tableA as n2 on n1.title = n2.title AND n1.id > n2.id;
并解释一下:n1.title = n2.title不使用索引。
n1.title = n2.title
这个查询会更好:
delete from `t2` where `id` in ( select cid from ( select max(id) as cid from t2 group by title having count(*) > 1 ) as c );