TRIM_IN
Descriptionβ
When there is no rhs
parameter, this function removes the leading and trailing spaces from the str
string. When the rhs
parameter is provided, it removes any characters from both ends of the string that are found in the rhs
character set (order does not matter).
Syntaxβ
TRIM_IN( <str> [ , <rhs>])
Required Parametersβ
Parameters | Description |
---|---|
<str> | Delete spaces at both ends of the string |
Optional Parametersβ
Parameters | Description |
---|---|
<rhs> | Remove the specified character |
Return Valueβ
Delete spaces at both ends or the string after the specified character
Returns VARCHAR type, representing the processed string.
Special cases:
- If str is NULL, returns NULL
- If rhs is not specified, removes all leading and trailing spaces
- If rhs is specified, removes all characters from both ends that appear in rhs until encountering the first character not in rhs
Examplesβ
- Remove spaces from both ends:
SELECT trim_in(' ab d ') str;
+------+
| str |
+------+
| ab d|
+------+
SELECT trim_in('ababccaab','ab') str;
+------+
| str |
+------+
| cc |
+------+