Last active
April 30, 2023 00:28
-
-
Save ntomka/fbf8e8b48690cecafe39 to your computer and use it in GitHub Desktop.
MySQL SPLIT_STRING function
This file contains hidden or 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
-- use this as a stored function | |
CREATE FUNCTION SPLIT_STRING(str VARCHAR(255), delim VARCHAR(12), pos INT) | |
RETURNS VARCHAR(255) | |
DETERMINISTIC | |
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos), | |
LENGTH(SUBSTRING_INDEX(str, delim, pos-1)) + 1), | |
delim, ''); |
ghost
commented
Feb 25, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment