SingleStore DB

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

Notice

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

SELECT TRIM('    ohai     ') AS t,
    -> TRIM(LEADING FROM '    ohai     ') AS l,
    -> TRIM(TRAILING FROM '    ohai     ') AS r;
+------+-----------+----------+
| t    | l         | r        |
+------+-----------+----------+
| ohai | ohai      |     ohai |
+------+-----------+----------+

SELECT TRIM("abra" FROM "abracadabra") AS t;
+------+
| t    |
+------+
| cad  |
+------+