Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Created January 23, 2024 15:11
Show Gist options
  • Save TimBHowe/e7d24a41f9650630c1183dfb4a1b2b6d to your computer and use it in GitHub Desktop.
Save TimBHowe/e7d24a41f9650630c1183dfb4a1b2b6d to your computer and use it in GitHub Desktop.
Return all the WooCommerce product and product variation prices set.
SELECT wp_posts.ID, wp_postmeta.meta_value AS sku, wp_posts.post_title AS title, wp_postmeta2.meta_value AS price FROM wp_posts
LEFT JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = '_sku' )
LEFT JOIN wp_postmeta AS wp_postmeta2 ON (wp_posts.ID = wp_postmeta2.post_id AND wp_postmeta2.meta_key = '_price' )
WHERE wp_posts.post_type = 'product'
OR wp_posts.post_type = 'product_variation'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment