Home > Database > Mysql Tutorial > body text

How to Capitalize First Letters in Existing MySQL Table Data?

DDD
Release: 2024-11-11 19:06:02
Original
480 people have browsed it

How to Capitalize First Letters in Existing MySQL Table Data?

Capitalizing First Letters in Existing Table Data

Many databases contain tables with fields populated with inconsistent letter casing, making it difficult to analyze or display data accurately. In MySQL, the "people_table" might have a "full_name" field with names like 'fred Jones', 'fred jones', or 'Fred jones'.

To find such entries, use the following query:

SELECT * FROM people_table WHERE full_name REGEXP BINARY '^[a-z]';
Copy after login

While MySQL lacks a built-in function to capitalize first letters, you can implement your own. Visit this link for an implementation: http://joezack.com/index.php/2008/10/20/mysql-capitalize-function/.

To use the function:

  1. Create it in the database (e.g., using MySQL Query Browser).
  2. Update the table values using a query like:
UPDATE users SET name = CAP_FIRST(name);
Copy after login

The above is the detailed content of How to Capitalize First Letters in Existing MySQL Table Data?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template