SELECT p.`id_product` FROM `750040_product` p LEFT JOIN `750040_category_product` cp ON (cp.`id_product` = p.`id_product`) INNER JOIN `750040_category_group` ctg ON (ctg.`id_category` = cp.`id_category`) INNER JOIN `750040_customer_group` cg ON (cg.`id_group` = ctg.`id_group`) WHERE p.id_supplier = 3 AND (cg.`id_customer` = 0 OR ctg.`id_group` = 1 AND p.`active` = 1 GROUP BY p.`id_product`