Last active
October 4, 2022 11:50
-
-
Save corsonr/cb4541c0c3d8303c6f5e to your computer and use it in GitHub Desktop.
Select or Delete WooCommerce Orphaned Variations
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
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' |
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
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why is r.ID uppercase on line 3 then lowercase on line 4? does this matter?
cheers