SQLite Trim Functions

SQLite support left trim (ltrim), right trim (rtrim), and both. The SQL trim function removes whitespace characters. The trim argument accepts up to two arguments though typically only one is used.

RTRIM

 
select 
         firstname || ' ' || lastname, 
  RTRIM(firstname) || ' ' || lastname
from person
where id in (6)
;

LTRIM

Please note that depending on the version of SQLite you use you may encounter an interesting side effect. If you comment out the where clause and run the query you will notice that SQLite adds the LTRIM explicitly to the firstname column.

select 
  firstname, 
  LTRIM(firstname) 
from person
--where id in (8,9)
; 

TRIM

 
select 
       firstname,
  TRIM(firstname)
from person
;

Schema and Data use on this page