Is it possible in mysql to format a column in Proper Case?
Example: Proper(\"ABSALOM\") = \"Absalom\"
I have searched a lot and I think MySQL d
-- set upper case the first char of every word in a string
DROP FUNCTION IF EXISTS PROPER;
DELIMITER $$
CREATE FUNCTION PROPER(inputStr varchar(1500))
RETURNS VARCHAR(1500)
DETERMINISTIC
BEGIN
DECLARE x, y, result VARCHAR(1500);
SET result = '';
SET x = '';
SET y = LOWER(TRIM(inputStr));
WHILE CHAR_LENGTH(y) > 0 DO
-- get next word
SET x = SUBSTRING_INDEX(y, ' ', 1);
-- set upper case the first char
SET x = CONCAT(UPPER(SUBSTRING(x, 1, 1)), SUBSTRING(x, 2));
-- the final s (greek language)
IF RIGHT(x,1) = 'σ' THEN
SET x = CONCAT(left(x, CHAR_LENGTH(x) - 1),'ς');
END IF;
-- add word to result
SET result = CONCAT(result, ' ', x);
-- prepare y for next loop
SET y = TRIM(SUBSTRING(y, CHAR_LENGTH(x) + 1));
END WHILE;
RETURN (TRIM(result));
END$$
DELIMITER;