Originally Posted by kshahborr1
Thank you. Would you have any sample code in sql you could share which I can refer to attain this.
Forum rules are preventing me from posting the url.
.. so posting the page here ---
MySQL does not include a function to split a delimited string. However, itís very easy to create your own function.
Create function syntax
A user-defined function is a way to extend MySQL with a new function that works like a native MySQL function.
CREATE [AGGREGATE] FUNCTION function_name
To create a function, you must have the INSERT privilege for the <mysql> database.
Split delimited strings
The following example function takes 3 parameters, performs an operation using an SQL function, and returns the result.
CREATE FUNCTION SPLIT_STR(
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
SELECT SPLIT_STR(string, delimiter, position)
SELECT SPLIT_STR('a|bb|ccc|dd', '|', 3) as third;
| third |
| ccc |