Created
September 13, 2016 11:15
-
-
Save JRGGRoberto/991aa24e51ce387926a04bfb047706aa to your computer and use it in GitHub Desktop.
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
DELIMITER $$ | |
CREATE FUNCTION SPLIT_STR( | |
x VARCHAR(255), | |
delim VARCHAR(12), | |
pos INT | |
) | |
RETURNS VARCHAR(255) DETERMINISTIC | |
BEGIN | |
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos), | |
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1), | |
delim, ''); | |
END$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Split no mysql
/!\ cuidado com espaço espaço, execute o trim!!!!
informe texto, caracter separador, e o indice
Exemplo
aa,bbb,ccc,ddd
SPLIT_STR(coluna, ',',2)
bbb