我們可以使用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中文網其他相關文章!