Extracting part of a string
am 23.11.2005 17:22:09 von laredotornado
Hello,
Using MySQL 4, how do I write a SELECT statement that returns the
portion of the string after the last comma in the string? That is, if
I have a field with a value
"a,b,c,d,e"
and
"a,b,c,eee"
I would like to write an SQL statement that returns "e" in the first
case and "eee" in the second case.
Thanks for your help, - Dave
Re: Extracting part of a string
am 23.11.2005 18:20:24 von zeldorblat
substring_index(someCol, ',', -1);
Re: Extracting part of a string
am 23.11.2005 21:24:13 von laredotornado
Thanks so much. That is very slick.
What if I wanted to get the first parts of the strings? That is,
"a,b,c,d" and "a,b,c"?
- Dave
Re: Extracting part of a string
am 24.11.2005 16:40:54 von zeldorblat
>What if I wanted to get the first parts of the strings? That is,
>"a,b,c,d" and "a,b,c"?
Don't know, but you might be able to find the answer here: