Last active
December 17, 2015 03:59
-
-
Save baniol/5547473 to your computer and use it in GitHub Desktop.
mysql split username, string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Splits username by first space, shortens first name to the first letter & adds a dot. Ex.: Jonh Smith -> J. Smith | |
SELECT CONCAT(CONCAT(LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX( `username` , ' ', 2 ),' ',1),1),"",". ") ," ", SUBSTRING_INDEX(SUBSTRING_INDEX( `username` , ' ', -1 ),' ',2)) AS user | |
FROM tbl_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment