Created
December 29, 2017 16:49
-
-
Save thedarsideofit/bc303aa0d33603273b97f60ad465d6cc to your computer and use it in GitHub Desktop.
Split function in Mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--https://stackoverflow.com/questions/5928599/equivalent-of-explode-to-work-with-strings-in-mysql | |
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, ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment