Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:54:39+00:00 2026-06-09T04:54:39+00:00

Can you parse a comma separated string into a temp table in MySQL using

  • 0

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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:54:40+00:00Added an answer on June 9, 2026 at 4:54 am

    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:

    CREATE FUNCTION SPLIT_STR(
      x VARCHAR(255),
      delim VARCHAR(12),
      pos INT
    )
    RETURNS VARCHAR(255)
    RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
           LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
           delim, '');
    

    (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:

    DELIMITER $$  
    
    CREATE PROCEDURE ABC(fullstr)
    
       BEGIN
          DECLARE a INT Default 0 ;
          DECLARE str VARCHAR(255);
          simple_loop: LOOP
             SET a=a+1;
             SET str=SPLIT_STR(fullstr,"|",a);
             IF str='' THEN
                LEAVE simple_loop;
             END IF;
             #Do Inserts into temp table here with str going into the row
             insert into my_temp_table values (str);
       END LOOP simple_loop;
    END $$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following line in Tcl to parse a comma-separated line of fields.
I need to convert a string of comma separated integers into a list of
How i can parse and extract the parameters from an SQL Query using delphi?
I need a PHP Regex that can parse .strings files. In particular, it needs
I'm using RSS library so i can parse Atom and RSS in Ruby and
How can I parse a String str = abc, \def,ghi\ ; such that I
Trying to write a regex that can parse a full name and split it
So I am trying to parse a list of emails separated by a comma
I am trying to figure out how to take a comma-separated string as input
How can I parse a float scanned from a sheet as text, containing commas?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.