웹이야기

[MySQL]TRIM() 본문

D/MySQL

[MySQL]TRIM()

yeon.Biju 2020. 6. 18. 09:58

MySQL 문자열 함수와 연산자

 

TRIM()

   -

 

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)

TRIM([remstr FROM] str)

의 형태

 

Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.

 

mysql> SELECT TRIM('   bar   ');
+-------------------+
| TRIM('   bar   ') |
+-------------------+
| bar               |
+-------------------+
1 row in set (0.00 sec)

mysql> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx') ;
+------------------------------------+
| TRIM(LEADING 'x' FROM 'xxxbarxxx') |
+------------------------------------+
| barxxx                             |
+------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx') ;
+---------------------------------+
| TRIM(BOTH 'x' FROM 'xxxbarxxx') |
+---------------------------------+
| bar                             |
+---------------------------------+
1 row in set (0.01 sec)

mysql> SELECT TRIM(TRAILING 'x' FROM 'xxxbarxxx') ;
+-------------------------------------+
| TRIM(TRAILING 'x' FROM 'xxxbarxxx') |
+-------------------------------------+
| xxxbar                              |
+-------------------------------------+
1 row in set (0.00 sec)


 

This function is multibyte safe.

 

'D > MySQL' 카테고리의 다른 글

[MySQL]UNHEX()  (0) 2020.06.18
[MySQL]UCASE()  (0) 2020.06.18
[MySQL]SUBSTRING_INDEX()  (0) 2020.06.11
[MySQL]SUBSTR()  (0) 2020.06.11
[MySQL]SPACE()  (0) 2020.06.11
Comments