I've been searching all over for the answer, I discovered about CASE, IFF and UNION but I haven't been able to figure it out, below is what I've been trying.
SELECT *
FROM car_label as a
INNER JOIN car as b
ON a.label_id = b.label_id
WHERE a.car_id = 619
UNION ALL
SELECT *
FROM car
WHERE car_id = 619
If the first select returns empty, I'd like to run the second select instead. This first part works perfectly, SELECT * FROM car_label as a INNER JOIN car as b ON a.label_id = b.label_id WHERE a.car_id = :car_id
, I'm just trying to include the second select in case the first is empty.
Update:
Message: 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF (SELECT * FROM car_label as a INNER JOIN car as' at line 1'