Skip to content

Instantly share code, notes, and snippets.

@kallookoo
Created November 12, 2025 07:48
Show Gist options
  • Select an option

  • Save kallookoo/07c482f76af955443d9b9b2e6700d90c to your computer and use it in GitHub Desktop.

Select an option

Save kallookoo/07c482f76af955443d9b9b2e6700d90c to your computer and use it in GitHub Desktop.
Retrieve WooCommerce products without images using SQL
SELECT
p.ID AS product_id,
sku.meta_value AS sku
FROM wp_posts AS p
LEFT JOIN wp_postmeta AS sku
ON sku.post_id = p.ID
AND sku.meta_key = '_sku'
LEFT JOIN wp_postmeta AS thumb
ON thumb.post_id = p.ID
AND thumb.meta_key = '_thumbnail_id'
WHERE
p.post_type = 'product'
AND thumb.meta_value IS NULL
ORDER BY p.ID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment