Skip to content
Advertisement

How can I use a list of variables in the “EXECUTE STATEMENT USING” statement MySQL?

I have the below procedure –

groupList‘ is a list of long variables. When calling the above procedure, I get the MySQL syntax error near ‘where groupid in ‘?’ ‘.

Looking on the Internet, I found that ? is a placeholder just for single variable and so we cannot use it for the list. Even if I create multiple ? variable like “?,?,?” and append it to the mysql query. How am I supposed to use the @groupList variable in “EXECUTE STATEMENT USING” statement?

I am calling the procedure as below –

Advertisement

Answer

When parsing a comma separated values as a input to aIN it will be considered as a string, so we need to use find_in_set.

Try the below query

To Call:
call testInjection('6598924, 6598928');

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement