Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete empty Woocommerce SKU
DELETE wp_posts,
wp_postmeta,
wp_comments,
wp_commentmeta
FROM wp_posts
LEFT JOIN wp_postmeta
ON wp_postmeta.post_id = wp_posts.ID
AND wp_postmeta.meta_key = '_sku'
LEFT JOIN wp_comments
ON wp_comments.comment_post_ID = wp_posts.ID
LEFT JOIN wp_commentmeta
ON wp_commentmeta.comment_id = wp_comments.comment_ID
LEFT JOIN wp_postmeta wpm2
ON wpm2.post_id = wp_posts.ID
WHERE wp_posts.post_type = 'product'
AND (wp_postmeta.meta_value= '' OR wp_postmeta.meta_value IS NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment