Created
May 17, 2018 16:47
-
-
Save jonpemby/e8f105939a407eca4d2482627bc8d736 to your computer and use it in GitHub Desktop.
Capitalize a string in MySQL
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
DELIMITER $$ | |
-- Capitalizes a word | |
-- @param str VARCHAR String to capitalize | |
-- @return VARCHAR Capitalized string | |
CREATE FUNCTION CAPITALIZE(str VARCHAR(255)) RETURNS VARCHAR(255) | |
BEGIN | |
RETURN CONCAT(UPPER(SUBSTRING(str, 1, 1)), SUBSTRING(str, 2)); | |
END$$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment