Wednesday, 25 July 2018

MySQL: UDF to SELECT value from a Comma Separated String at any position

In this post, I am sharing one user defined function to select a particular value from comma separated string in the MySQL.
In our MySQL Database, we are managing some of the table in which we are storing dynamic content management system (CMS) related data.
As per the requirement, we are also storing comma delimited values in some the tables.
Now the requirement is to find third value from each comma separated string.
I have created one user defined function to solve this problem.
First, Create UDF to split and select a particular value from comma separated string:
Three parameters require: Delimited_String, Delimited_Character, and Position.
Create a table with sample data:
Using UDF, SELECT second value from each comma separated string:
The Result:


MySQL Comma Separated Values

0 comments:

Post a Comment