RTRIM
Descriptionβ
The RTRIM function is used to remove consecutive spaces or specified characters from the right side (trailing) of a string.
Syntaxβ
RTRIM( <str> [, <trim_chars> ] )
Parametersβ
Parameter | Description |
---|---|
<str> | The string that needs to be trimmed. |
<trim_chars> | Optional parameter. If this parameter is provided, the RTRIM function will remove all characters in <trim_chars> that appear on the right side of <str> . If this parameter is not provided, the RTRIM function will only remove the space characters on the right side of <str> . |
Return Valueβ
Returns a string with trailing spaces or <trim_chars>
removed. Special cases:
- If any Parameter is NULL, NULL will be returned.
Examplesβ
SELECT rtrim('ab d ') str;
+------+
| str |
+------+
| ab d |
+------+
SELECT rtrim('ababccaab','ab') str;
+---------+
| str |
+---------+
| ababcca |
+---------+