Below are two stored procedures for MySQL community server version 8.0.11. I have seen some stored procedures written the first way using the back-quote: `, character in the parameter list and query statement. However, I have also seen queries written like the second one where there are no back-quote characters.
Which way is the best practice to follow? Are they any security differences? If one uses the back-quote character in stored procedures are they more vulnerable to SQL injection attacks?
CREATE PROCEDURE `procedure`(IN `in_data` VARCHAR(100))
BEGIN
SELECT COUNT(*) FROM `table_name` WHERE `data` = `in_data`;
END
Or:
CREATE PROCEDURE `procedure`(IN in_data VARCHAR(100))
BEGIN
SELECT COUNT(*) FROM table_name WHERE data = in_data;
END
I hope I made this clear enough, thank you for your time.