Skip to content

Instantly share code, notes, and snippets.

@yratof
Created December 10, 2017 22:16
Show Gist options
  • Save yratof/2d3bbb33750fa159f1193248cb189896 to your computer and use it in GitHub Desktop.
Save yratof/2d3bbb33750fa159f1193248cb189896 to your computer and use it in GitHub Desktop.
Remove duplicate products
DELETE a.*
FROM wp_posts AS a
INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
FROM wp_posts
WHERE post_type = 'product'
AND post_status = 'publish'
GROUP BY post_title
HAVING COUNT( * ) > 1
) AS b ON b.post_title = a.post_title
AND b.min_id <> a.id
AND a.post_type = 'product'
AND a.post_status = 'publish'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment