MK
SELECT p.ID, p2.post_parent FROM wp_posts as p
LEFT JOIN wp_term_relationships as tr ON p.ID = tr.object_id
LEFT JOIN wp_terms as t ON tr.term_taxonomy_id = t.term_id
LEFT JOIN
(
SELECT p2.post_parent FROM wp_posts as p2
WHERE p2.post_type = 'product_variation'
) p2
ON p.ID = p2.post_parent
WHERE p.post_type = 'product' AND p.post_parent = 0
AND t.name = 'variable'
AND p2.post_parent IS NULL