LTRIM
Removes leading characters, including spaces, from an expr string.
Syntax
LTRIM(expr[, trim_chars])Arguments
expr: The value of the STRING data type.
trim_chars: One or more characters of the STRING data type to be removed from the left side of expr. If no characters are specified, spaces are removed.
Return Value
The return value is of the STRING data type.
Usage Notes
The order of characters in the trim_chars argument is not considered.
If multiple characters are specified as trim_chars, spaces must be explicitly included in the argument to remove spaces. Example: The expression '@ ,' would remove all leading spaces, @-signs, and commas from the input string. The expression '@,' would only remove @-signs and commas from the input string.
Tab characters, newline characters, and other 'whitespace' characters must be explicitly specified.
Example 1
SELECT LTRIM('#073400', '0#') AS RESULT1,
LTRIM('#000734', '0#') AS RESULT2,
LTRIM('0#002734', '0#') AS RESULT3,
LTRIM(' 0 0 0734è#', '0# ') AS RESULT4,
LTRIM(' 0 0 07 34è#', '0# ') AS RESULT5;+---------+---------+---------+---------+---------+
| RESULT1 | RESULT2 | RESULT3 | RESULT4 | RESULT5 |
+---------+---------+---------+---------+---------+
| 73400 | 734 | 2734 | 734è# | 7 34è# |
+---------+---------+---------+---------+---------+Example 2 | LTRIM and Specific Whitespace Characters
Tab characters, newline characters, and other 'whitespace' characters must be explicitly specified.
expr contains a tab character ('chr(9)'), which was explicitly specified in the trim_chars argument in the query and thus could be removed (expr_trimmed1), and was not explicitly specified in the query for expr_trimmed2 and thus could not be removed.
select ('"' || chr(9)||'Lorem ipsum'|| '"') as expr,
length('"' || chr(9)||'Lorem ipsum'|| '"') as expr_len,
ltrim('"' || chr(9)||'Lorem ipsum'|| '"',('"'||chr(9))) as expr_trimmed1,
length(ltrim('"' || chr(9)||'Lorem ipsum'|| '"',('"'||chr(9)))) as expr_trimmed1_len,
ltrim('"' || chr(9)||'Lorem ipsum'|| '"',('"'||' ')) as expr_trimmed2,
length(ltrim('"' || chr(9)||'Lorem ipsum'|| '"',('"'||' '))) as expr_trimmed2_len;+----------------+----------+---------------+-------------------+---------------+-------------------+
| EXPR | EXPR_LEN | EXPR_TRIMMED1 | EXPR_TRIMMED1_LEN | EXPR_TRIMMED2 | EXPR_TRIMMED2_LEN |
+----------------+----------+---------------+-------------------+---------------+-------------------+
| " Lorem ipsum" | 14 | Lorem ipsum" | 12 | Lorem ipsum" | 13 |
+----------------+----------+---------------+-------------------+---------------+-------------------+