FULL NAME TO FIRST, MIDDLE, LAST IN MYSQL
UPDATE student t
JOIN (
SELECT
id,
first AS full_name,
-- Extract first name (first part)
SUBSTRING_INDEX(first, ' ', 1) AS f_name,
-- Extract middle name (everything between first and last)
CASE
WHEN LENGTH(first) - LENGTH(REPLACE(first, ' ', '')) >= 2
THEN SUBSTRING_INDEX(SUBSTRING_INDEX(first, ' ', 2), ' ', -1)
ELSE ''
END AS m_name,
-- Extract last name (last part)
SUBSTRING_INDEX(first, ' ', -1) AS l_name
FROM student
) x ON t.id = x.id
SET
t.first = x.f_name,
t.middle = x.m_name,
t.last = x.l_name;
Note : update your_table to required table name
