First of all, I will request you to go through this LINK link in order to realize the cons of storing a delimited list in a column.
Anyway, if you achieve this task using MySql, then you need to do it using Procedure and Function as follows:
Step 1: Create a Function to split data with delimiter , with given position.
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, '');
Now, the above function will split data only for the given position. In order to split whole string, we need to iterate this function. That's our step 2.
Step 2: Create Procedure to iterate the above function;
CREATE PROCEDURE ABC(IN fullstr varchar(1000))
BEGIN
DECLARE a INT Default 0;
DECLARE str VARCHAR(255);
DECLARE prev VARCHAR(255);
simple_loop: LOOP
SET a=a+1;
IF a=1 THEN
SET prev=SPLIT_STR(fullstr,",",a);
SET a=a+1;
END IF;
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 t1 values (prev,str);
SET prev=str;
END LOOP simple_loop;
Step 3: Call Procedure:
call abc(columnName);
Step 4: Get data from temp table:
select *
from temp;
Hope it helps!