MySQL Strings Segmentation

SUBSTRING_INDEX(str, delim, count) str: the string to be split. delim: the delimiter. count: the position of the delimiter. A positive number means extract from left to right, a negative number means extract from right to left. For example: SELECT SUBSTRING_INDEX('100-200-300-400', '-', 1); — output: '100' SELECT SUBSTRING_INDEX('100-200-300-400', '-', 2); — Read more…