将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)
使用插入命令将一些记录插入表中 –
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)
阅读更多:MySQL 教程