Skip to content

Instantly share code, notes, and snippets.

@SuN-80
Created February 20, 2018 12:37
Show Gist options
  • Save SuN-80/7dae3ede7507f8e8a5236ef1586eecfc to your computer and use it in GitHub Desktop.
Save SuN-80/7dae3ede7507f8e8a5236ef1586eecfc to your computer and use it in GitHub Desktop.
Flip First and Last Names in MySQL
-- "Lastname, Firstname" to "Firstname Lastname"
UPDATE mytable set field = CONCAT(
TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(field,',',2),',',-1)),
' ',
TRIM(SUBSTRING_INDEX(field,',',1))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment