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


基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01