Skip to content

Instantly share code, notes, and snippets.

@kallookoo
Last active January 28, 2026 03:03
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,
p.post_title AS TITLE,
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