On 16-Jun-2003 Tom Johnson wrote: > Is it possible to convert the following query to run in MySQL? The query > is > based on a table called "ardata" which contains the fields 'author', > 'lname', and 'fname'. The 'author' field contains the authors first and > last name with a space in the middle. I want to convert the names over > so > the first and last names are in separate fields. I was given this query > based on MS SQL but the PATINDEX( ) doesn't work in MySQL. Any > suggestions? > > UPDATE ardata SET > author = LTRIM ( RTRIM ( author )), > lname = SUBSTRING ( author, PATINDEX ( '% %', name ) + 1, LEN ( name )), > fname = SUBSTRING ( author, PATINDEX ( '% %', name )); > author =TRIM(author), fname=SUBSTRING_INDEX(author, ' ', 1), lname=SUBSTRING_INDEX(author, ' ', -1)
Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. (53kr33t w0rdz: sql table query) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]