Skip to content

Instantly share code, notes, and snippets.

@anaxamaxan
Created February 26, 2015 17:09
Show Gist options
  • Save anaxamaxan/b5298a8455339f879b3c to your computer and use it in GitHub Desktop.
Save anaxamaxan/b5298a8455339f879b3c to your computer and use it in GitHub Desktop.
small tweak for tessa
UPDATE `tbl_name` SET
`first_name` = IF(
LOCATE(' ', `name`) > 0,
SUBSTRING(`name`, 1, LOCATE(' ', `name`) - 1),
`name`
),
`last_name` = IF(
LOCATE(' ', `name`) > 0,
SUBSTRING_INDEX(`name`, ' ' - 1), /* Changed line */
NULL
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment