SELECT p.product_id, p.price, (SELECT MIN(pd.price) FROM product_discount pd WHERE pd.product_id = p.product_id AND pd.customer_group_id = '1' AND pd.quantity > '0' AND ((pd.date_start = '0000-00-00' OR pd.date_start < '2017-07-23') AND (pd.date_end = '0000-00-00' OR pd.date_end > '2017-07-23'))) AS discount, (SELECT MIN(ps.price) FROM product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < '2017-07-23') AND (ps.date_end = '0000-00-00' OR ps.date_end > '2017-07-23'))) AS special FROM product p LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p2s.store_id = '0' AND p.status = '1' AND p.price > '0' AND p2c.category_id = '9' AND p.date_available <= '2017-07-23' ORDER BY p.price