Practice
as is well known, MySQL doesn't have a built-in explode function, but it can be emulated, and with UTF-8 support, meaning it supports Cyrillic - Russian letters
CREATE DEFINER=`root`@`%`
FUNCTION `explode`(delimiter VARCHAR(12),string TEXT, indexWord INT)
RETURNS varchar(255) CHARSET utf8mb4
DETERMINISTIC
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(string , delimiter , indexWord ),
CHAR_LENGTH(SUBSTRING_INDEX(string , delimiter , indexWord -1)) + 1),delimiter , '')
It's very important to use CHAR_LENGTH specifically, instead of LENGTH.
usage example

If you need to return many rows (a collection), you can use a function like this
you need to have a table
temp_table_collection(id, one_word) with at least 2 fields, and create a stored function
usage example
After running it, each entry after the comma will be inserted into the temporary table temp_table_collection
thanks)
Comments