You are viewing an older version of this section. View current production version.
Join the SingleStore Community Today
Get expert advice, develop skills, and connect with others.

TRIM

Removes padding from the ends of the given string.

Syntax

TRIM ([[BOTH | LEADING | TRAILING] [padding] FROM] str)

Arguments

  • padding: any string or binary object (optional, defaults to " “)
  • str: any string or binary object

If no keyword is specified, defaults to BOTH.

Return Type

String

Examples

Info

This function removes only space " " characters. Other whitespace characters like tab \t, newline \n, etc are preserved.

memsql> select trim('    ohai     ') as t,
    -> trim(LEADING FROM '    ohai     ') as l,
    -> trim(TRAILING FROM '    ohai     ') as r;
+------+-----------+----------+
| t    | l         | r        |
+------+-----------+----------+
| ohai | ohai      |     ohai |
+------+-----------+----------+

memsql> select trim("abra" FROM "abracadabra") as t;
+------+
| t    |
+------+
| cad  |
+------+

Related Topics