This function is used to remove characters from the left of str.
Similar functions:
ltrim([<trimChars>,] string <str>)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String from which characters on the left 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 stringabc is returned.
select ltrim(' abc');
It is equivalent to the following statement:
select trim(leading from ' abc');
leading indicates that the leading spaces in a string are removed.
The value NULL is returned.
select ltrim(null); select ltrim('xy', null); select ltrim(null, 'xy');
The function returns lucyxx, as any substring starting with x or y from the left end is removed.
select ltrim( 'xy','yxlucyxx');
It is equivalent to the following statement:
select trim(leading 'xy' from 'yxlucyxx');