MySQL trim function
MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string.
Syntax
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)
Arguments
| Name | Description |
|---|---|
| BOTH | Indicates that prefixes from both left and right are to be removed. |
| LEADING | Indicates that only leading prefixes are to be removed. |
| TRAILING | Indicates that only trailing prefixes are to be removed. |
| remstr | The string to be removed. |
| FROM | Keyword |
| str | The actual string from where remstr is to be removed. |
Example
mysql> SELECT TRIM(' trim ');
+----------------+
| trim |
+----------------+
1 row in set (0.00 sec)