Capitalizing First Letter of Each Word in an Existing Table
Problem:
Many records in the people_table have incorrect casing in the full_name field, such as 'fred Jones' or 'Fred jones'. The goal is to capitalize the first letter of each word without disrupting the existing data.
Solution:
MySQL does not provide a built-in function to capitalize the first letter of each word. However, external functions can be created for this purpose.
One such function, called CAP_FIRST, can be implemented as described in the following resource:
http://joezack.com/index.php/2008/10/20/mysql-capitalize-function/
Implementation:
UPDATE people_table SET full_name = CAP_FIRST(full_name);
This operation will capitalize the first letter of each word in the full_name field, correcting the incorrect casing.
The above is the detailed content of How to Capitalize the First Letter of Each Word in a MySQL Table?. For more information, please follow other related articles on the PHP Chinese website!