SQLite ltrim() Function

SQLite ltrim() function removes leading spaces or other specified characters from a string. The ltrim() function returns a new string with leading characters removed.

Syntax

ltrim(string,[character])Code language: SQL (Structured Query Language) (sql)

Arguments

The ltrim() function accepts two arguments:

string

The input string that you want to remove leading specified characters.

character

Is the character that you want to remove. It is an optional argument.

If you specify it, the ltrim() function will remove all the characters at the beginning of the string.

If you omit the character argument, the ltrim() function will remove the spaces at the beginning of the string.

Return Type

TEXT

Examples

The following statement uses the ltrim() function to return a string with spaces at the beginning of the string removed.

SELECT ltrim('  SQLite') result;Code language: SQL (Structured Query Language) (sql)

Output:

result
------
SQLite

The following example uses the ltrim() function to remove the $ character at the beginning of a USD amount:

SELECT ltrim('$599.99', '$') amount;Code language: SQL (Structured Query Language) (sql)

Output:

amount
------
599.99Code language: CSS (css)

See Also

trim, rtrim

Was this tutorial helpful ?