First we need to create function which return index value of comma separated value
CREATE FUNCTION `SPLIT_STR`(
x VARCHAR(255),
delim VARCHAR(12),
pos INT
) RETURNS varchar(255) CHARSET utf8mb3
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
delim, '')
Then Create virtual recursive table from current value
with recursive new_table as (
select value ,LENGTH(t.value) - LENGTH(REPLACE(t.value, ',', '')) as n ,1 as x from table t limit 1
union all
select value, n,1+x as x from new_table where x <= n
)
select TRIM(SPLIT_STR(value,',',x)) as value from new_table
will return
| value |
| honda |
| activa |
| pleasure |
| car |