当前title在article表下的值,例如:
- 示例标题1
- 示例标题2
- 示例标题3
我必须把第一个字符改为大写,后面的字符改为小写。
在事务之后应该如下所示:
- 示例标题1
- 示例标题2
- 示例标题3
我应该使用哪个SQL命令来使用MySQL查询更改标题的所有数据并永久更改?
显然,这是有效的:
CONCAT(UPPER(SUBSTRING(title, 1, 1)),LOWER(SUBSTRING(title, 2)))
使用ucfirst();
函数。首先在一个变量中检索它,然后将它传递给ucfirst();
函数并回显答案。
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>