Question: I have a table with a column 'Name', like the following:

```
    Name
Michael Jackson
Chester Bennington
Mike Shinoda

```

I want to split the 'Name' values in FirstName and LastName,blike this:

```
LastName          FirstName
Jackson          Michael
Bennington       Chester
Shinoda          Mike

```

And also I need to create new columns and add those values, all in a single query if its possible.
So as a review, I have Name, I need to create LastName, FirstName columns, split the Name values after the first blank space,the value before the blank space will go into LastName and the values after the blank space will go into FirstName. This is what I have tried so far:

```
ALTER TABLE `data` ADD `FirstName` VARCHAR(30),ADD `LastName` VARCHAR(30)  
INSERT INTO `data`(`LastName`,`FirstName`) VALUES ('...','...') 

```

Help please..

Answer: 
Try this

```
UPDATE data SET FirstName = SUBSTRING_INDEX(Name, ' ', 1), LastName = SUBSTRING(SUBSTRING_INDEX(Name, ' ', 2),
       LENGTH(SUBSTRING_INDEX(Name, ' ', 1)) + 1)

```

**EDIT**

As David Faber stated, one can use `SUBSTRING_INDEX(Name, ' ', -1)` for updating the `LastName` column.
INSTR shows error, so used POSITION. I am trying to split the columns at character '/':

```
UPDATE pincode
   SET latitude = LEFT( coordinates, POSITION('/' IN coordinates) - 1 )
     , longitude = RIGHT( coordinates, LENGTH(coordinates) - POSITION('/' IN coordinates) )
 WHERE coordinates LIKE '%/%';

```