I have the following query that I can't seem to get working. I am using MySQL 5.0. The query will eventually go into a stored procedure but for now I am just trying to get it to work in Query Browser. It has been a while since I have used MySQL and I certainly have not done conditionals.
Any help would be greatly appreciated!
Code:
DECLARE InputItemID int;
SET InputItemID = 1;
IF ISNULL(InputItemID) THEN
SELECT a.AttributesAutomobileID, a.AttributesAutomobileName
FROM attributesautomobiles a
ORDER BY a.AttributesAutomobileName ASC;
ELSE
SELECT a.AttributesAutomobileID, a.AttributesAutomobileName, b.AttributesAutomobileID as CheckAutomobileID
FROM attributesautomobiles a
LEFT OUTER JOIN itemautomobile b ON b.ItemID = InputItemID
AND b.AttributesAutomobileID = a.AttributesAutomobileID
ORDER BY a.AttributesAutomobileName ASC;
END IF;
Regards,
Piet