Skip to content

Instantly share code, notes, and snippets.

@JAW-Dev
Created April 8, 2020 13:59
Show Gist options
  • Save JAW-Dev/aab6ddf9d67173d9fd181fa47b6aea61 to your computer and use it in GitHub Desktop.
Save JAW-Dev/aab6ddf9d67173d9fd181fa47b6aea61 to your computer and use it in GitHub Desktop.
Low Stock
SELECT p.post_title as 'Name', pm.meta_value as 'SKU', pm2.meta_value as 'Stock'
FROM wp_posts p
INNER JOIN wp_postmeta pm
ON p.ID = pm.post_id
INNER JOIN wp_postmeta pm2
ON p.ID = pm2.post_id
AND pm.meta_key = '_sku'
AND ((pm2.meta_key = '_stock' AND pm2.meta_value = '0' ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment