SQLite 3 reference · String Functions

SQLite TRIM() Function

Remove spaces, or any characters you list, from both ends of a string. Spaces inside the string are kept.

SQLite 3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

trim(X, Y)

Parameters

ParameterDescription
X The string (other values are converted to text).
Y optional The characters to remove; spaces by default.

Return value

The trimmed string.

Examples

Remove spacesTry it yourself
SELECT '[' || trim('   hello   ') || ']' AS trimmed;

Output

trimmed
[hello]
Remove other charactersTry it yourself
SELECT trim('--==Title==--', '-=') AS title,
       trim('007', '0') AS no_zeros;

Output

title | no_zeros
Title | 7

In other languages

Was this page helpful?