Skip to main content

TRIM

Returns a string formed by removing spaces, or any of a given set of characters, from both ends of an input string.

See also:
[SELECT] [LTRIM] [RTRIM]


Syntax​

SELECT TRIM(character_expression[, character ]) FROM <multipartIdentifier>;

Arguments​

character_expression
A literal string or string column.

character
An optional string of characters: every character in it is removed from the beginning and end of the character_expression. If omitted, spaces are removed (not tabs or newlines).

Return Value(s)​

Returns a string.


Examples​

Remove leading and trailing spaces from a string column​

SELECT trim(description) AS leading_and_trailing_whitespace_removed
FROM google.compute.instances
WHERE project = 'stackql-demo'
AND zone = 'australia-southeast1-a';

For more information, see https://www.sqlite.org/lang_corefunc.html#trim