11、將字串所有字母都改為小寫的(lcase或者lower)
用法:
lcase/lower(str)
eg:
mysql> select lcase('wuzhiming') from user;
+--------------------+
| lcase('wuzhiming') |
+--------------------+
| wuzhiming |
| wuzhiming |
| wuzhiming |
| wuzhiming |
+--------------------+
4 rows in set (0.00 sec)
12、獲取字串左邊n個字元(left)
用法:
left(str,n)返回字串str最左邊的x個字元
mysql> select left('wuzhiming',2) from user;
+---------------------+
| left('wuzhiming',2) |
+---------------------+
| wu |
| wu |
| wu |
| wu |
+---------------------+
4 rows in set (0.03 sec)
13、獲取字串的長度(length)
用法:
length(str)
eg:
mysql> select length('wuzhiming') from user;
+---------------------+
| length('wuzhiming') |
+---------------------+
| 9 |
| 9 |
| 9 |
| 9 |
+---------------------+
4 rows in set (0.00 sec)
14、去掉字串開頭的空格(ltrim)
用法:
ltrim(str)
mysql> select ltrim(' wuzhiming') from user;
+-------------------------+
| ltrim(' wuzhiming') |
+-------------------------+
| wuzhiming |
| wuzhiming |
| wuzhiming |
| wuzhiming |
+-------------------------+
4 rows in set (0.00 sec)
15、獲取子串在字串中第一次出現的位置(locate)
用法:
locate(str,substr)
mysql> select locate('ming' , 'wuzhiming');
+------------------------------+
| locate('ming' , 'wuzhiming') |
+------------------------------+
| 6 |
+------------------------------+
1 row in set (0.00 sec)
16、用反斜槓注意字串中的單引號(quote)
用法:
quote(str)
17、獲取字串重複幾次後的結果(repeat)
用法:
repeat(str,count)
eg:
mysql> select repeat('mysql',2);
+-------------------+
| repeat('mysql',2) |
+-------------------+
| mysqlmysql |
+-------------------+
1 row in set (0.00 sec)
18、獲取字串反轉後的結果(reverse)
用法:
reverse(str)
eg:
mysql> select reverse('abcd')
-> ;
+-----------------+
| reverse('abcd') |
+-----------------+
| dcba |
+-----------------+
1 row in set (0.00 sec)
19、獲取字串最右邊n個字元(right)
用法:
right(str, count)
eg:
mysql> select right('wuzhiming', 4);
+-----------------------+
| right('wuzhiming', 4) |
+-----------------------+
| ming |
+-----------------------+
1 row in set (0.00 sec)
20、去除字串尾部的空格(rtrim)
用法:
rtrim(str)
eg:
mysql> select rtrim('wuzhiming ');
+------------------------+
| rtrim('wuzhiming ') |
+------------------------+
| wuzhiming |
+------------------------+
1 row in set (0.00 sec)
MySQL學習 四 常用MySQL函式
函式一般與查詢語句巢狀使用 字串函式 char length str 返回字串str包含的字元數 concat char1 char2 合併字串 select insert 替換字串,從某個位置開始替換某個長度 select lower str 將str轉換為小寫 select upper str ...
MySQL語句大全(2)常用函式
常用函式 abs 1 絕對值 pi pi值 sqrt 2 平方根 mod 5,3 取餘 2ceil 10.6 進製 1結果11 ceil 10.0 結果10 floor 10.6 取整10round 2.5 四捨五入到整數 結果3 round 2.5,2 保留兩位小數 結果2.50truncate ...
Keras學習筆記2 常用函式
全連線層 詳細請看 keras 中文文件 keras是什麼?1.dense 全連線層 2.keras.layer.input 用於例項化keras張量 3.activation 啟用函式 4.dropout 正則化層 5.flatten 展平 6.reshape 調整輸入大小 7.lambda 將任...