Capitalize first letter. MySQL(首字母大写.MySQL)
问题描述
有人知道 MySQL 中这个 TSQL 的等价物吗?
Does any one know the equivalent to this TSQL in MySQL parlance?
我正在尝试将每个条目的第一个字母大写.
I am trying to capitalize the first letter of each entry.
UPDATE tb_Company SET CompanyIndustry = UPPER(LEFT(CompanyIndustry, 1))
+ SUBSTRING(CompanyIndustry, 2, LEN(CompanyIndustry))
推荐答案
几乎一样,你只需要改用 CONCAT() 函数而不是 + 运算符:
It's almost the same, you just have to change to use the CONCAT() function instead of the + operator :
UPDATE tb_Company
SET CompanyIndustry = CONCAT(UCASE(LEFT(CompanyIndustry, 1)),
SUBSTRING(CompanyIndustry, 2));
这会将 hello 变成 Hello,wOrLd 变成 WOrLd,BLABLA到 BLABLA 等.如果你想大写第一个字母,小写另一个,你只需要使用 LCASE 函数:
This would turn hello to Hello, wOrLd to WOrLd, BLABLA to BLABLA, etc. If you want to upper-case the first letter and lower-case the other, you just have to use LCASE function :
UPDATE tb_Company
SET CompanyIndustry = CONCAT(UCASE(LEFT(CompanyIndustry, 1)),
LCASE(SUBSTRING(CompanyIndustry, 2)));
注意 UPPER 和 UCASE 做同样的事情.
Note that UPPER and UCASE do the same thing.
这篇关于首字母大写.MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:首字母大写.MySQL
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
