Slava Rozhnev, Нужно было определить минимальную цену на каждый товар и поставщика(-ов). Решил вопрос через временную таблицу.
CREATE TEMPORARY TABLE `tmp_min_price`
SELECT p.product_id,MIN(p.price) m_price
FROM products p
WHERE p.price IS NOT NULL
GROUP BY p.product_id ;
UPDATE `products` p
LEFT JOIN `tmp_min_price` mp ON mp.product_id = p.product_id AND mp.m_price = p.price
SET p.is_min_price = 1 WHERE mp.product_id IS NOT NULL
CREATE TEMPORARY TABLE `tmp_min_price`
SELECT p.product_id,MIN(p.price) m_price
FROM products p
WHERE p.price IS NOT NULL
GROUP BY p.product_id ;
UPDATE `products` p
LEFT JOIN `tmp_min_price` mp ON mp.product_id = p.product_id AND mp.m_price = p.price
SET p.is_min_price = 1 WHERE mp.product_id IS NOT NULL