This function is used to remove characters from the right of str.
Similar functions:
rtrim([<trimChars>, ]string <str>)
or
rtrim(trailing [<trimChars>] from <str>)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String from which characters on the right are to be removed. If the value is of the BIGINT, DECIMAL, DOUBLE, or DATETIME type, the value is implicitly converted to the STRING type for calculation. |
trimChars |
Yes |
STRING |
Characters to be removed |
The return value is of the STRING type.
The value yxabcxx is returned.
select rtrim('yxabcxx ');
It is equivalent to the following statement:
select trim(trailing from ' yxabcxx ');
The function returns yxabc, as any substring starting with x or y from the right end is removed.
select rtrim('xy', 'yxabcxx');
It is equivalent to the following statement:
select trim(trailing 'xy' from 'yxabcxx');
The value NULL is returned.
select rtrim(null); select ltrim('yxabcxx', 'null');