Skip to content

Instantly share code, notes, and snippets.

@corsonr
Last active October 4, 2022 11:50
Show Gist options
  • Save corsonr/cb4541c0c3d8303c6f5e to your computer and use it in GitHub Desktop.
Save corsonr/cb4541c0c3d8303c6f5e to your computer and use it in GitHub Desktop.
Select or Delete WooCommerce Orphaned Variations
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'
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'
@modul4richard
Copy link

why is r.ID uppercase on line 3 then lowercase on line 4? does this matter?

cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment