Skip to main content Link Menu Expand (external link) Document Search Copy Copied

TRIM() function

TRIM() function removes the leading and trailing whitespace from a specified string in the selected column.

Syntax

trim(expr)

Arguments

Argument Description
expr Any string expression.

Returns

Data type Value
string expr with leading and trailing whitespace removed.

Examples

Trim strings from a column

create table segments
    (_id id, segment string);

insert into segments(_id,segment)
    values (1,'   green   ')

select _id, trim(segment) as TrimmedStr from segments;

+-----+------------+
| _id | TrimmedStr |
+-----+------------+
|   1 | green      |
+-----+------------+