select pd.product_id, d.name, d.discount_percent, d.discount_amount
from s_products_discount pd
inner join s_discounts d
on (pd.discount_id = d.id
and d.visible = 1
and d.date_from <= '2018-05-05'
and d.date_to >= '2018-05-05')
where pd.product_id
in ('41987', '41988', '41989', '41990',
'41991', '41992', '41993', '41994')
having max(d.priority);
echo '<option value="'.$g[id].'" ' . $sel . ($g['id'] == 5 ? 'style="color:red;"' : '') . '>'.$g[name].' '.$g[currency].'</option>';