Yes it is possible
SELECT m.*, t.*
FROM merchants m
JOIN (
SELECT MAX(`date`) as max_date, id
FROM prices
WHERE `date` <= ?
GROUP BY id
) t ON t.id = m.id
Edit : 2 steps queries
Assuming your shop is displaying 20 products per pages. You can run a 1st query like this :
SELECT m.*
FROM merchants m
WHERE some_criterias
LIMIT 20 OFFSET 0
and then you pass the result of this 1st query to the 2nd one :
SELECT m.*, t.*
FROM merchants m
JOIN (
SELECT MAX(`date`) as max_date, p.merchant_id
FROM prices p
AND merchant_id IN (?, ?, ?...)
WHERE `date` <= ?
GROUP BY id
) t ON t.merchant_id = m.id
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…