Created
August 26, 2014 00:19
-
-
Save tivnet/ae7b9d590fc21730e8f5 to your computer and use it in GitHub Desktop.
SQL: WooCommerce product IDs by stock status and backorders
This file contains 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 _stock, _stock_status, _backorders, GROUP_CONCAT( PID ) | |
FROM ( | |
SELECT | |
post_id AS PID, | |
meta_value AS _stock, | |
( | |
SELECT meta_value | |
FROM wp_postmeta | |
WHERE post_id = PID | |
AND meta_key = '_stock_status' | |
) _stock_status, | |
( | |
SELECT meta_value | |
FROM wp_postmeta | |
WHERE post_id = PID | |
AND meta_key = '_backorders' | |
) _backorders | |
FROM `wp_postmeta` | |
WHERE meta_key = '_stock' | |
) v | |
GROUP BY _stock, _stock_status, _backorders |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment