I have two table users_new and users_old with some count of rows.
I would like to insert data from users_old to users_new by using insert select.
Table users_old has one field name, which contains first name and last name.
Table users_new must have two fields, first name (name)and last name (surname).
I don't know how combine them. Any advice?
SET @str="";
SET @firstName="";
SET @lastName="";
INSERT INTO users_new (name, surname)
VALUES(
SELECT @firstName,@lastName;
@str=select name
FROM users_old
SET @firstName = SUBSTRING_INDEX(@str, ' ', 1);
SET @lastName=LTRIM(REPLACE(@str, @firstName, ''))
);