Example
I’m trying to create a stored procedure you can call with or without an argument. Is this possible? Moreover, if you supply an argument it will select columns below OR if that name is null if not select just select all
DELIMITER ##
CREATE PROCEDURE showStuff(IN stuff varchar(45))
BEGIN
SELECT
d.NAME,
s.SIGN,
c.FACE
FROM Format f
JOIN SIGNAL s ON s.SIG_ID=f.SIG_ID
JOIN DEPT d on d.DEP_ID=s.DEP_ID
JOIN CHIM c ON c.F_ID=f.F_ID
WHERE IF(stuff IS NULL, d.NAME=stuff, ??);
ORDER BY d.NAME;
END ##
DELIMITER ;
Kinda like this, although your SQL code is wrong itself.