[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String Manipulation


On 09 Dec 2005 10:45:04 +0800, Jeffrey G. Ubalde
> I have been thinking about this for hours, and I cant quite get the
> correct keyword for me to search it in the manual.
>
> for example i have a field that contains string1:string2:string3
> where colon ':' is the delimiter.
>
> How do i create a select statement that only returns string2?

Something like this may be what you're after?

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

mysql> select substring_index(substring_index('string1:string2:string3',':',2),':',-1);
+--------------------------------------------------------------------------+
| substring_index(substring_index('string1:string2:string3',':',2),':',-1) |
+--------------------------------------------------------------------------+
| string2                                                                  |
+--------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>


Will.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.