Consider the following query:
SELECT p.*
FROM product p
LEFT JOIN product_time pt ON p.id = pt.product_id
WHERE pt.time BETWEEN ? AND ?
AND pt.type = 'PRODUCTION_DATE';
I need to change my query so that it will filter first by "RELEASE_DATE". If a production_time with the type "RELEASE_DATE" does not exist, filter by "PRODUCTION_DATE". How would I go about doing this?