trim()

Removes any occurrences of any of the characters from either side of the string. characters defaults to space.

Arguments & returns

2 overloads

trim(string)

Scalar
Overload link string Returns
#01 VARCHAR VARCHAR

trim(string, characters)

Scalar
Overload link stringcharacters Returns
#02 VARCHARVARCHAR VARCHAR

Example

1 more ↓
trim example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

More examples

trim example 2
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In a query

Turn a label into a useful key.

Trim the edges, normalize case, and replace runs of spaces. Small functions compose into a readable cleaning step.

Turn a label into a useful key.
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Guide recipe · Run to view results.

In other engines

PostgreSQLbtrim()

SELECT BTRIM(x, 'ab')
In Haybarn
SELECT TRIM(x, 'ab')

SQLGlot example ↗

ClickHouse

SELECT LTRIM(s), RTRIM(s), TRIM(s)
In Haybarn
SELECT LTRIM(s), RTRIM(s), TRIM(s)

SQLGlot example ↗