Assuming there are no parts of a name that include more than one word
(e.g., "Mary Jo" being someone's first name), an easy way would be to
use SUBSTRING_INDEX.

First Name = SUBSTRING_INDEX( namefield, ' ', 1 );
Middle Name = SUBSTRING_INDEX( SUBSTRING_INDEX( namefield, ' ', 2 ), ' ', -1 );
Last Name = SUBSTRING_INDEX ( namefield, ' ', -1 );

http://dev.mysql.com/doc/mysql/en/String_functions.html

Wes



On Wed, 08 Sep 2004 13:35:07 +0000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> How can I extract a middle segment of text in mySQL.  For example a column contains 
> this string: 'William Walker Jones'.  I need to split this into the first, middle, 
> and last names.  I can easily extract the first and last names but how do I extract 
> the Middle name?
>

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to