Remove duplicate media entries from mysql database
I am wondering if you can help.
I have a wordpress site with 90000 media entries, but only 1000 images. I do not want to remove the images from the media gallery just the entries in the database that have been duplicated.
I know that you can find the duplicates in the wordpress admin area using a plugin however they delete all the images rather than just the duplicated database entries.
SELECT posts.ID, posts.post_title AS title, posts.post_content AS content, files.meta_value AS filepath
FROM fc0cy_posts posts
INNER JOIN fc0cy_posts attachments ON posts.ID = attachments.post_parent
INNER JOIN fc0cy_postmeta files ON attachments.ID = files.post_id
WHERE files.meta_key = '_wp_attached_file'
I have the select query, just not the delete one. I am wondering if anyone with more sql knowledge can help to convert it please.
Topic duplicates media-library mysql media Wordpress
Category Web