Skip to content

Instantly share code, notes, and snippets.

@maycomayco
Created April 10, 2018 19:20
Show Gist options
  • Save maycomayco/d76e6e329e1f11538a37d7d5e497fc3c to your computer and use it in GitHub Desktop.
Save maycomayco/d76e6e329e1f11538a37d7d5e497fc3c to your computer and use it in GitHub Desktop.
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