我们可以使用 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)
以上是我们可以使用哪些 MySQL 函数来更改字符串的字符大小写?的详细内容。更多信息请关注PHP中文网其他相关文章!