MySQL
- 1 ответ
- 0 вопросов
1
Вклад в тег
SELECT
pd.product_id,
d.name,
d.discount_percent,
d.discount_amount
FROM s_products_discount pd
JOIN s_discounts d ON pd.discount_id = d.id
WHERE 1
AND pd.product_id IN ('41987', '41988', '41989', '41990', '41991', '41992', '41993', '41994') # проверять список ид ДО более сложной проверки
AND d.priority = (
SELECT MAX(sd.priority)
FROM s_products_discount spd
JOIN s_discounts sd on spd.discount_id = sd.id
WHERE spd.product_id = pd.product_id
AND sd.visible = 1
AND sd.date_from <= '2018-05-05'
AND sd.date_to >= '2018-05-05'
)