trim

This function is used to remove characters from the left and right of str.

Similar functions:

Syntax

trim([<trimChars>,]string <str>)

or

trim([BOTH] [<trimChars>] from <str>)

Parameters

Table 1 Parameters

Parameter

Mandatory

Type

Description

str

Yes

STRING

String from which characters on both left and right are to be removed

If the value is of the BIGINT, DECIMAL, DOUBLE, or DATETIME type, the value is implicitly converted to the STRING type for calculation.

trimChars

No

STRING

Characters to be removed

Return Values

The return value is of the STRING type.

  • If the value of str is not of the STRING, BIGINT, DOUBLE, DECIMAL, or DATETIME type, an error is reported.
  • If the value of str or trimChars is NULL, NULL is returned.

Example Code