Home > Database > Mysql Tutorial > 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
Release: 2024-11-20 01:08:02
Original
949 people have browsed it

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));
Copy after login

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!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template