将 MySQL 列中的每个值的字母全部转换为大写
为此,请对 MySQL 列使用 UPPER()。我们首先创建一个表 −
mysql> create table DemoTable627 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,FirstName varchar(100)); Query OK, 0 rows affected (0.62 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable627(FirstName) values(UPPER('John')); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Sam')); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Mike')); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('Carol')); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable627(FirstName) values(UPPER('dAVID')); Query OK, 1 row affected (0.70 sec)
使用 select 语句显示表中的所有记录 −
mysql> select *from DemoTable627;
这将产生以下输出 −
+----+-----------+ | Id | FirstName | +----+-----------+ | 1 | JOHN | | 2 | SAM | | 3 | MIKE | | 4 | CAROL | | 5 | DAVID | +----+-----------+ 5 rows in set (0.00 sec)
广告