MySQL split data into two additional columns

I have a table with 3 columns, FullName, FirstName and LastName

FullName is the only column with data as it includes a full name such as John Smith with the normal space between the first and last names.

I need to get the John into the FirstName and Smith into the Lastname

Can someone show me the exact MySQL syntax to populate to the two other columns with the data from the FullName for the entire table?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


if all names only have one first name use:

SELECT substring(FullName,1, locate(' ',FullName)-1) as FirstName,  
             substring(FullName,locate(' ',FullName)+1) as LastName

for it to work with people with more that one first name (i.e. John Ryan Smith):

SELECT substring(FullName,1,length(FullName)- locate(' ',reverse(FullName))) as FirstName,  
             substring(FullName,length(FullName)- locate(' ',reverse(FullName))+ 2) as LastName

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
just to add to Wizard's reply....the select statement returns FullName in two populate the two empty columns in your table as you described you might use an UPDATE

using Wizard's code::

UPDATE your_table_name SET FirstName = substring(FullName,1, locate(' ',FullName)-1),  
              LastName = substring(FullName,locate(' ',FullName)+1);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.