如何小写整个字符串在MYSQL中保持第一个大写 [英] How to lowercase the whole string keeping the first in uppercase in MYSQL

查看:28
本文介绍了如何小写整个字符串在MYSQL中保持第一个大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格栏 -

我预期的输出在列中发生变化 -

My expected Output to change in column -

Smith, Allen, Doyle, Dennis, Baker, Waker

这是我尝试过的,但不起作用:(-

This is what i tried, but not working :( -

UPDATE TABLE `employee`
SET last_name = UCASE(LEFT(lower(last_name), 1))

UPDATE TABLE `employee`
SET last_name = ucase(lower(last_name),1)

也关注了这个链接 - 资源

Followed this link too - Resource

错误 --

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE `employee` SET last_name = UCASE(LEFT(lower(last_name), 1))' at line 1

让我知道我做错了什么以及如何解决.

Let me know what I am doing wrong and how to fix.

推荐答案

TABLE 是保留关键字.应该用反引号转义.

TABLE is a reserved keyword. It should be escaped with backtick.

我认为 TABLE 不应该出现在您的查询中,(我认为这是一个错字)

I think TABLE should not be in your query, (i think it is a typo)

UPDATE employee
SET last_Name = CONCAT(UCASE(LEFT(last_Name, 1)), LCASE(SUBSTRING(last_Name, 2)))

  • SQLFiddle 演示
  • 这篇关于如何小写整个字符串在MYSQL中保持第一个大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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