I have a large SQL query (MySQL 5.7.32) that gets all sorts of data AND is including pricing data for a particular day, if there is price data available for this day. Done by a simple LEFT JOIN:
SELECT *
FROM merchants m CROSS JOIN products p
LEFT JOIN prices mps
ON m.id = mps.id AND p.article_id = mps.article_id AND mps.DATE = $date
In some cases there is no price for this particular day. In that case I would like to get the last recent price available.
Is this possible with LEFT JOIN or do I have to add even more complexity to my statement?