让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Name varchar(100) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('JOhn'); mysql> insert into DemoTable values('CHRIS'); mysql> insert into DemoTable values('DAVID'); mysql> insert into DemoTable values('RObert');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+--------+ | Name | +--------+ | JOhn | | CHRIS | | DAVID | | RObert | +--------+ 4 rows in set (0.00 sec)
以下是在MySQL中将整个字符串保持小写的查询-
mysql> update DemoTable -> set Name= CONCAT(UCASE(LEFT(Name, 1)), LCASE(SUBSTRING(Name, 2))); Rows matched: 4 Changed: 4 Warnings: 0
让我们再次检查表中的所有记录。
mysql> select *from DemoTable;
输出结果
+--------+ | Name | +--------+ | John | | Chris | | David | | Robert | +--------+ 4 rows in set (0.00 sec)