Can you parse a comma separated string into a temp table in MySQL using RegEx?
'1|2|5|6' into temp table with 4 rows.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is pretty much the same question as Can Mysql Split a column?
MySQL doesn’t have a split string function so you have to do work arounds. You can do anything with the data once you split it using one of the methods listed on the answer page above.
You can loop over that custom function and break when it returns empty, you’ll have to play and learn some syntax (or at least I would) but the syntax for a FOR loop in mysql is here:
http://www.roseindia.net/sql/mysql-example/for.shtml
You can iterate over it, incrementing the position in the function below:
(Credit: https://blog.fedecarg.com/2009/02/22/mysql-split-string-function/ )
Which should return ” if no match is found, so break the loop if no match is found. This will allow you to with only mysql parse over the split string and run the insert queries into a temp table. But man why not just use a scripting language like php for that kind of work? 🙁
Code for loop syntax: