This function is used to remove characters from the left and right of str.
Similar functions:
trim([<trimChars>,]string <str>)
or
trim([BOTH] [<trimChars>] from <str>)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String from which characters on both left and 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 |
No |
STRING |
Characters to be removed |
The return value is of the STRING type.
The value yxabcxx is returned.
select trim(' yxabcxx ');
It is equivalent to the following statement:
select trim(both from ' yxabcxx '); select trim(from ' yxabcxx ');
The function returns Txyom, as any substring starting with x or y from both the left and right ends is removed.
select trim('xy', 'yxabcxx');
It is equivalent to the following statement:
select trim(both 'xy' from 'yxabcxx');
The value NULL is returned.
select trim(null); select trim(null, 'yxabcxx');