我们可以使用LCASE()
和LOWER()
函数将字符串的字符大小写更改为小写,UCASE()
以及使用UPPER()
函数将字符串的字符大小写更改为大写。
mysql> Select LCASE('NEW DELHI'); +--------------------+ | LCASE('NEW DELHI') | +--------------------+ | new delhi | +--------------------+ 1 row in set (0.00 sec) mysql> Select LOWER('NEW DELHI'); +--------------------+ | LOWER('NEW DELHI') | +--------------------+ | new delhi | +--------------------+ 1 row in set (0.00 sec) mysql> Select UCASE('new delhi'); +--------------------+ | UCASE('new delhi') | +--------------------+ | NEW DELHI | +--------------------+ 1 row in set (0.00 sec) mysql> Select UPPER('new delhi'); +--------------------+ | UPPER('new delhi') | +--------------------+ | NEW DELHI | +--------------------+ 1 row in set (0.00 sec)
我们还可以将这些函数与表的列一起使用。例如,假设我们要更改输出中一列中值的字符大小写,然后对表“ Student”进行查询可以证明它-
mysql> Select Name, UCASE(Name) from student; +---------+-------------+ | Name | UCASE(Name) | +---------+-------------+ | Gaurav | GAURAV | | Aarav | AARAV | | Harshit | HARSHIT | | Gaurav | GAURAV | | Yashraj | YASHRAJ | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, LCASE(Name) from student; +---------+-------------+ | Name | LCASE(Name) | +---------+-------------+ | Gaurav | gaurav | | Aarav | aarav | | Harshit | harshit | | Gaurav | gaurav | | Yashraj | yashraj | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, UPPER(Name) from student; +---------+-------------+ | Name | UPPER(Name) | +---------+-------------+ | Gaurav | GAURAV | | Aarav | AARAV | | Harshit | HARSHIT | | Gaurav | GAURAV | | Yashraj | YASHRAJ | +---------+-------------+ 5 rows in set (0.00 sec) mysql> Select Name, LOWER(Name) from student; +---------+-------------+ | Name | LOWER(Name) | +---------+-------------+ | Gaurav | gaurav | | Aarav | aarav | | Harshit | harshit | | Gaurav | gaurav | | Yashraj | yashraj | +---------+-------------+ 5 rows in set (0.00 sec)