Skip to content

Instantly share code, notes, and snippets.

@thedarsideofit
Created December 29, 2017 16:49
Show Gist options
  • Save thedarsideofit/bc303aa0d33603273b97f60ad465d6cc to your computer and use it in GitHub Desktop.
Save thedarsideofit/bc303aa0d33603273b97f60ad465d6cc to your computer and use it in GitHub Desktop.
Split function in Mysql
--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