All products and variation sql query
-
Hi
I am running the following query but it seems to be missing the product name on 18000 products and variations but returns the product name for the other 25000
SELECT
p.id,
mt.meta_value AS sku,
m.meta_value AS stock,
p.post_title AS title,
pt.meta_value AS price,
wt.meta_value AS weight
FROM
wp_posts p
INNER JOIN wp_postmeta m ON (
p.id = m.post_id
)
INNER JOIN wp_postmeta mt ON (
p.id = mt.post_id
)
INNER JOIN wp_postmeta pt ON (
p.id = pt.post_id
)
INNER JOIN wp_postmeta wt ON (
p.id = wt.post_id
)
WHERE
(p.post_type = ‘product’ OR p.post_type = ‘product_variation’)
AND
m.meta_key = ‘_stock’
AND
mt.meta_key = ‘_sku’
AND
pt.meta_key = ‘_price’
AND
wt.meta_key = ‘_weight’So my question would be why doesnt this query bring back from MySQL all the product names?
Is there another field that might have the product name in it because it might be a slightly different product?I used WP import from ebay to bring in all my products
- The topic ‘All products and variation sql query’ is closed to new replies.