Answer the question
In order to leave comments, you need to log in
How to remove duplicates by ID in MySQL?
Hello! I want to remove duplicates on the site, since they are easy to find by ID:
SELECT id, COUNT(*) as count
FROM wp_posts
GROUP BY id
HAVING COUNT(*) > 1
Answer the question
In order to leave comments, you need to log in
Try like this:
CREATE table wp_posts_copy LIKE wp_posts;
ALTER TABLE wp_posts_copy ADD PRIMARY KEY (id);
INSERT INGORE INTO wp_posts_copy SELECT * FROM wp_posts; -- INSERT INGORE вставит только по одному экземпляру id.
DROP TABLE wp_posts;
RENAME TABLE wp_posts_copy TO wp_posts;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question