if you want to capitalize each first letter through MySQL, you can write a function, and write SQL directly to update the column, here is the sample code:
DELIMITER $$
CREATE FUNCTION CAP_FIRST_CHAR (input VARCHAR(255))
RETURNS VARCHAR(255)
BEGIN
DECLARE length INT;
DECLARE i INT;
SET length = CHAR_LENGTH(input);
SET input = LOWER(input);
SET i = 0;
WHILE (i < length) DO
IF (MID(input,i,1) = ‘ ‘ OR i = 0) THEN
IF (i < length) THEN
SET input = CONCAT(LEFT(input,i),UPPER(MID(input,i + 1,1)),RIGHT(input,length – i – 1));
END IF;
END IF;
SET i = i + 1;
END WHILE;
RETURN input;
END$$
DELIMITER ;
update table set table_col=CAP_FIRST_CHAR(table_col);
Tags: capitalize, mysql