首字母大写.MySQL [英] Capitalize first letter. MySQL

查看:33
本文介绍了首字母大写.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 变成 HellowOrLd 变成 WOrLdBLABLABLABLA 等.如果你想大写第一个字母,小写另一个,你只需要使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆