大写第一个字母.的MySQL [英] Capitalize first letter. MySQL

查看:112
本文介绍了大写第一个字母.的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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