SQL LCASE()
SQL LCASE() 函數
LCASE() 函數
LCASE() 函數把欄位的值轉換成小寫。
SQL LCASE() 語法
SELECT LCASE(column_name) FROM table_name;
用於SQL Server 的語法
SELECT LOWER(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 LCASE(name) AS site_title, url
FROM Websites;執行上述SQL 輸出結果如下: