SQLite: trim Function
This SQLite tutorial explains how to use the SQLite trim function with syntax and examples.
Description
The SQLite trim function removes all specified characters from both sides of a string.
Syntax
The syntax for the trim function in SQLite is:
trim( string, [ trim_string ] )
Parameters or Arguments
- string
- The string to trim the characters from.
- trim_string
- The string that will be removed from both sides of string. If this parameter is omitted, the trim function will remove both leading and trailing space characters from string.
Applies To
The trim function can be used in the following versions of SQLite:
- SQLite 3.8.6, SQLite 3.8.x, SQLite 3.7.x, SQLite 3.6.x
Example
Let's look at some SQLite trim function examples and explore how to use the trim function in SQLite.
For example:
sqlite> SELECT trim(' TechOnTheNet.com '); Result: 'TechOnTheNet.com' sqlite> SELECT trim(' TechOnTheNet.com is great! '); Result: 'TechOnTheNet.com is great!' sqlite> SELECT trim('000123000', '0'); Result: '123' sqlite> SELECT trim('321123totn123123', '123'); Result: 'totn' sqlite> SELECT trim('zTOTNxyxzyyy', 'xyz'); Result: 'TOTN' sqlite> SELECT trim('42totn6372', '0123456789'); Result: 'totn'
Advertisements