Home  >  Article  >  Database  >  How do I capitalize the first letter of each entry in a MySQL column?

How do I capitalize the first letter of each entry in a MySQL column?

Susan Sarandon
Susan SarandonOriginal
2024-11-20 01:08:02901browse

How do I capitalize the first letter of each entry in a MySQL column?

Capitalizing the First Letter: MySQL Equivalent

Q: How can I capitalize the first letter of each entry in MySQL?

A: The equivalent MySQL syntax for the provided TSQL statement is as follows:

UPDATE tb_Company
SET CompanyIndustry = CONCAT(UCASE(LEFT(CompanyIndustry, 1)), SUBSTRING(CompanyIndustry, 2));

This query updates the CompanyIndustry column by capitalizing the first letter of each entry.

Variations:

  • To lowercase the remaining characters, use LCASE(SUBSTRING(CompanyIndustry, 2)) instead of SUBSTRING(CompanyIndustry, 2).
  • To use uppercase for the first letter and lowercase for the remaining characters, use UCASE(LEFT(CompanyIndustry, 1)) and LCASE(SUBSTRING(CompanyIndustry, 2)), respectively.

Note that UPPER and UCASE are equivalent functions for converting to uppercase.

The above is the detailed content of How do I capitalize the first letter of each entry in a MySQL column?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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