Skip to content
SQLSimplified
string

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

NameDescriptionOptional
stringThe text to trim on the left.No
charsCharacters to remove (default space).Yes

Return Type

Returns a VARCHAR.

Examples

Loading playground environment...
Loading playground environment...

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. LTRIM leaves trailing spaces; use TRIM for 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 REPLACE for inside.

See also: RTRIM, TRIM, REPLACE.

Cite this resource

SQLSimplified. "LTRIM() SQL Function". Available at: https://sqlsimplified.online/reference/ltrim