So currently I have data in my table like
Numbers (Varchar 255)
111|1232|234
434|234
12546|3243|3434
23434|34
35465|3434
Current, the column is VARCHAR but I'm planning to convert it into JSON field so I'm trying to make them json or array before converting the field.
I tried following this
CREATE FUNCTION SPLIT_STRING(str VARCHAR(255), delim VARCHAR(12), pos INT)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos),
LENGTH(SUBSTRING_INDEX(str, delim, pos-1)) + 1),
delim, '');
But it seems I have to manually specify index.