Last active
November 29, 2016 23:48
-
-
Save jameshiggins/ae402877c107ec5f87a237332e92b5dd to your computer and use it in GitHub Desktop.
Select Then Delete WooCommerce orphaned products
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALWAYS BACKUP YOUR DATABASES BEFORE THIS OPERATION | |
SELECT * FROM `wp_posts` o | |
LEFT OUTER JOIN `wp_posts` r | |
ON o.post_parent = r.ID | |
WHERE r.id IS null AND o.post_type = 'product_variation' | |
DELETE o FROM `wp_posts` o | |
LEFT OUTER JOIN `wp_posts` r | |
ON o.post_parent = r.ID | |
WHERE r.id IS null AND o.post_type = 'product_variation' | |
DELETE pm | |
FROM wp_postmeta pm | |
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id | |
WHERE wp.ID IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment