I implementing stored procedure in mysql for convenient inserting in many-to-many intermediate table. My table have two column: chat_id
and participant_id
.
I have an api method, that takes chat_id and string with participant_ids separated by commas like "add_participants?chat_id=1&participant_ids=1,2,3"
I want stored procedure that can deal with this. Think this is very generic problem in web. But I cant figure out syntax, that will produce me this by parameters chat_id='1'
andparticipant_ids='1,2,3'
Asked
Active
Viewed 731 times
1
-
As I know group_concat() concatenates multiple values to one string, but I need to insert multiple values from comma separated list. – simd Mar 10 '15 at 18:07
-
2Mysql doesn't have a split function. There are several posts on SO how to do this. http://stackoverflow.com/questions/11835155/mysql-split-comma-separated-string-into-temp-table . . . http://stackoverflow.com/a/19073575/1073631 – sgeddes Mar 10 '15 at 18:55