using mysql variable to hold comma separated value to be used for where in clause
问题 I have to run a query like this (query 1) - select something from sometable where someId in (1,2,3) I would like to keep a variable for the IDs part, like this (query 2) - set @myIds = "1,2,3"; select something from sometable where someId in (@myIds); But this does not give the expected result (gives an empty result set), and no query error as well. I checked that if I wrap the comma separated IDs inside quotes, the query results an empty result set (query 3) - select something from sometable