LTRIM()
Removes leading (left-side) characters, usually spaces, from a string.
Description
LTRIM strips characters from the start (left) of a string. By default it
removes spaces, which is useful for cleaning fixed-width or padded input. You
can pass a second argument to remove specific leading characters.
Syntax
LTRIM(string)
LTRIM(string, chars)Parameters
| Name | Description | Optional |
|---|---|---|
| string | The text to trim on the left. | No |
| chars | Characters to remove (default space). | Yes |
Return Type
Returns a VARCHAR.
Examples
Employees & Departments
Loading database engine...
Employees & Departments
Loading database engine...
LTRIM vs TRIM
LTRIM only removes from the left; TRIM removes from both ends. Use RTRIM
for the right side.
Common Mistakes
- Expecting both sides trimmed.
LTRIMleaves trailing spaces; useTRIMfor both. - Wrong argument order. In most engines the characters to remove come
second:
LTRIM(string, chars). - Trimming the middle. It only touches the start; use
REPLACEfor inside.
Related Functions
See also: RTRIM, TRIM, REPLACE.