I am writing a small query to grab image path and object ID from Woo_Commerce database. I am join taxonomy and relationship table to achieve this but somehow I am making mistake I can't realize. I have my category comparison set and path is coming from post_meta but somehow not giving the two columns. The category that I am intersted is just the term_ID that I want to pass (16). So I want all object ID that has term_ID 16 and the second column is their image path.
Object ID | ImgPath
SELECT object_id as productID, meta_value as imgPath FROM wp_term_relationships as wp_re INNER JOIN wp_postmeta as pthGiver INNER JOIN wp_term_taxonomy as termIDgiver on wp_re.object_id = pthGiver.post_id AND pthGiver.meta_key = '_wp_attached_file' WHERE termIDgiver.`term_taxonomy_id` = '16'
As you can see in the following image WordPress is grabbing all the products and their images by category I want
term_taxonomy_id = '16' which is diamond. How is WordPress filtering?