DROP TABLE IF EXISTS temp_eav_check;
CREATE TABLE temp_eav_check AS
            SELECT `eav`.`entity_id`, 
                   MAX(CASE WHEN eav.attribute_id = 175 THEN eav.value ELSE NULL END) AS `line`,
                   MAX(CASE WHEN eav.attribute_id = 166 THEN eav.value ELSE NULL END) AS `part`
            FROM `catalog_product_entity_varchar` AS `eav`
            WHERE eav.attribute_id IN (175, 166)
            GROUP BY `eav`.`entity_id`;
            
            
SELECT temp_eav_check.*, catalog_product_entity_tier_price.qty, xlentparts_ebaystoremanager_activelisting.item_id, catalog_product_entity.sku  FROM temp_eav_check            
LEFT JOIN xlentparts_partsauthority_inventorydata AS paInv 
            ON temp_eav_check.line = paInv.line AND temp_eav_check.part = paInv.part
LEFT JOIN catalog_product_entity_tier_price ON catalog_product_entity_tier_price.entity_id = temp_eav_check.entity_id
LEFT JOIN catalog_product_entity ON catalog_product_entity.entity_id = catalog_product_entity_tier_price.entity_id
LEFT JOIN xlentparts_ebaystoremanager_activelisting ON xlentparts_ebaystoremanager_activelisting.sku = catalog_product_entity.sku
WHERE paInv.inventorydata_id IS NULL
AND xlentparts_ebaystoremanager_activelisting.item_id IS NOT NULL