TRIM()
All functions > STRING > TRIM()
Returns the string with whitespace from both ends removed.
Signatures
Returns: String with leading and trailing whitespace removed
TRIM(string: VARCHAR) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to trim |
Notes
- Removes leading and trailing whitespace (spaces, tabs, line breaks, and similar)
- Whitespace inside the string is left unchanged
TRIM('')is''; if the input is NULL the result is NULL (useNULL(VARCHAR); bareNULLfails inference)
Examples
FeatureQL
SELECT
f1 := TRIM(' hello '), -- Trim both ends
f2 := TRIM(' world '), -- Trim tabs
f3 := TRIM(' mixed spaces '), -- Only trim ends
f4 := TRIM('no trim needed'), -- No whitespace to trim
f5 := TRIM(NULL(VARCHAR)), -- NULL yields NULL
f6 := TRIM(CONCAT(CHR(10), 'hello', CHR(10))) -- Line breaks at both ends
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR | f6 VARCHAR |
|---|---|---|---|---|---|
| hello | world | mixed spaces | no trim needed | NULL | hello |
On this page