我們可以使用 LCASE() 和 LOWER() 函數(shù)將字符串的字符大小寫更改為小寫,使用 UCASE() 和 UPPER() 函數(shù)將字符串的字符大小寫更改為大寫。
示例
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)
登錄后復(fù)制
我們還可以將這些函數(shù)與表的列一起使用。例如,假設(shè)我們想要更改輸出中列中值的字符大小寫,然后對表“Student”進(jìn)行以下查詢可以演示它 –
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)
登錄后復(fù)制
以上就是我們可以使用哪些 MySQL 函數(shù)來更改字符串的字符大小寫?的詳細(xì)內(nèi)容,更多請關(guān)注www.92cms.cn其它相關(guān)文章!