Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › Database

How to Capitalize the First Letter of Each Word in a MySQL Column

By Freedom251 Team · · 2 min read

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MySQL 8.4 does not document a built-in INITCAP() function. To capitalize the first letter of every word, you need to define what counts as a word boundary and apply that rule in application code or a custom SQL routine. If you only mean the first character of the whole value, a short SQL expression will do it.

Capitalize only the first character of the value

Use UPPER() on the first character, then append the remainder unchanged:

As an Amazon Associate I earn from qualifying purchases.

SELECT CONCAT(UPPER(LEFT(name, 1)), SUBSTRING(name, 2)) AS capitalized_name
FROM people;

For example, mYSQL guide becomes MYSQL guide. This changes only the initial character; it does not capitalize the first letter of each word. MySQL documents UPPER(), LEFT(), SUBSTRING(), and CONCAT() in its MySQL 8.4 string-function reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Lowercase the rest only if that is intended

If your desired normalization is an initial capital followed by lowercase characters, use:

SELECT CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTRING(name, 2))) AS normalized_name
FROM people;

This turns mYSQL guide into Mysql guide. It also changes acronyms and intentional internal capitals, so do not use it when those must be preserved.

Capitalize the first letter of every word

There is no simple UPPER() expression that finds and capitalizes every word boundary. Decide whether a boundary means a space only or also includes punctuation, hyphens, and apostrophes. Then implement that specific rule in application code or a custom stored routine. For example, these inputs raise different rule questions: mary jane, mary-jane, and o'connor.

For general text, application-side processing is often simpler because the code can make the boundary, Unicode, and lowercasing choices explicit. A stored routine can be appropriate when the transformation must run inside MySQL, but it still needs a defined rule; do not treat it as a universal title-case operation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apply a transformation to stored values carefully

For the one-character transformation, preview the result before changing the table:

SELECT name,
       CONCAT(UPPER(LEFT(name, 1)), SUBSTRING(name, 2)) AS proposed_name
FROM people;

If the preview is correct and you have protected values that must remain unchanged, the corresponding update is:

UPDATE people
SET name = CONCAT(UPPER(LEFT(name, 1)), SUBSTRING(name, 2));

This update changes the first character of each value only. It is not a per-word capitalization solution. To avoid overwriting values outside the intended scope, add a suitable WHERE condition or process a reviewed set of rows.

Check character sets and binary data

MySQL case conversion uses character-set mappings. The manual notes that LOWER() and UPPER() do not work on binary strings such as BINARY, VARBINARY, and BLOB; convert binary data to a nonbinary string using the correct character set before applying case conversion. For simple string functions, the result character set and collation follow the principal input value. You can inspect an expression with CHARSET() and COLLATION(). See the MySQL 8.4 string-function documentation and the MySQL 8.0 function-result character set and collation notes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do not confuse MySQL with PostgreSQL

PostgreSQL documents initcap(text), but that function is not part of the documented MySQL 8.4 string-function set. PostgreSQL also notes that word splitting and results can vary with locale provider and ICU version. A query copied from PostgreSQL that calls INITCAP(name) should not be assumed to work in MySQL. See the PostgreSQL 19 string-functions documentation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

DatabaseMySQLSQLString Functions

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.