2.7TRIM(str):返回字符串str,所有前綴或后綴被刪除了。
1.LTRIM(str):返回刪除了其前置空格字符的字符串str。
2.RTRIM(str):返回刪除了其拖后空格字符的字符串str。
實例
MariaDB [study_db]> SELECT TRIM(' ???HUAGN ?');
+---------------------+
| TRIM(' ???HUAGN ?') |
+---------------------+
| HUAGN ??????????????|
+---------------------+
1 row in set (0.00sec)
2.8替換REPLACE(str, from_str, to_str):返回字符串str,其字符串from_str的所有出現由字符串to_str代替。
MariaDB[study_db]>SELECTREPLACE('NODEJS','JS','study');
+----------------------------------+
| REPLACE('NODEJS','JS','study') |
+----------------------------------+
| NODEstudy ???????????????????????|
+----------------------------------+
1rowinset (0.00sec)
2.9 REPEAT(str,count):返回由重復countTimes次的字符串str組成的一個字符串。如果count <= 0,返回一個空字符串。如果str或count是NULL,返回NULL。
MariaDB [study_db]>SELECTREPEAT('HHW',24);
+--------------------------------------------------------------------------+
| REPEAT('HHW',24) ???????????????????????????????????????????????????????|
+--------------------------------------------------------------------------+
| HHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHWHHW |
+--------------------------------------------------------------------------+
1rowinset (0.00sec)
2.10.1REVERSE(str):返回顛倒字符順序的字符串str。
MariaDB[study_db]>SELECTREVERSE('123456');
+-------------------+
|REVERSE('123456') |
+-------------------+
|654321|
+-------------------+
1rowinset (0.00sec)
2.10.2SUBSTRING(str, pos):取出str前pos個字符,返回剩余的字符;
MariaDB [study_db]>SELECTSUBSTRING('ABCDEFGHIJKLMN',4);
+--------------------------------+
| SUBSTRING('ABCDEFGHIJKLMN',4) |
+--------------------------------+
| DEFGHIJKLMN ???????????????????|
+--------------------------------+
1rowinset (0.00sec)
2.10.3 INSERT(str,pos,len,newstr):返回字符串str,在位置pos起始的子串且len個字符長的子串由字符串newstr代替。
MariaDB [study_db]> SELECT INSERT('1234567890',4,2, 'mariadb');
+---------------------------------------+
| INSERT('1234567890',4,2, 'mariadb') |
+---------------------------------------+
|123mariadb67890 ??????????????????????|
+---------------------------------------+
1row in set (0.00sec)