SQL UCASE()
SQL UCASE() 函數
UCASE() 函數
UCASE() 函數把欄位的值轉換成大寫。
SQL UCASE() 語法
SELECT UCASE(column_name) FROM table_name;
用於SQL Server 的語法
SELECT UPPER(column_name) FROM table_name;
#示範資料庫
在本教學中,我們將使用php 樣本資料庫。
下面是選自"Websites" 表的資料:
+----+--------------+--- ------------------------+-------+---------+
| id | name | url | alexa | country |
+----+----------+------------------------------------ --------+-------+---------+
| 1 | Google | https://www.google.cm/ | 1 | USA | 1 |
| 2 | 淘寶 | https://www.taobao.com/ | 13 | CN cn/ | 4689 | CN |
| 4 | 微博 | http://weibo.com/ | 201 https://www.facebook.com/ | 3 | USA |
| 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND |
+----+---------------+----------- ------------------+-------+---------+
| id | name | url | alexa | country |
+----+----------+------------------------------------ --------+-------+---------+
| 1 | Google | https://www.google.cm/ | 1 | USA | 1 |
| 2 | 淘寶 | https://www.taobao.com/ | 13 | CN cn/ | 4689 | CN |
| 4 | 微博 | http://weibo.com/ | 201 https://www.facebook.com/ | 3 | USA |
| 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND |
+----+---------------+----------- ------------------+-------+---------+
下面的SQL 語句從"Websites" 表中選取"name" 和"url" 列,並將"name" 列的值轉換為大寫:
#實例SELECT UCASE(name) AS site_title, url
FROM Websites;執行上述SQL 輸出結果如下: