SQL TRIM
Remove spaces (or given characters) from the ends of text.
Syntax
TRIM(text) LTRIM(text) RTRIM(text)
Example
Query (on the shop database used in the SQL course)
SELECT '[' || TRIM(' padded ') || ']' AS trimmed, TRIM('xxhixx', 'x') AS custom;
Result
| trimmed | custom |
|---|---|
| [padded] | hi |
1 row
Related
Learn it step by step in the free lesson Functions: Text, Numbers, Dates & CASE, with exercises that check your queries.