MySQL trim function

MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string.

Syntax

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)

Arguments

NameDescription
BOTHIndicates that prefixes from both left and right are to be removed.
LEADINGIndicates that only leading prefixes are to be removed.
TRAILINGIndicates that only trailing prefixes are to be removed.
remstrThe string to be removed.
FROMKeyword
strThe actual string from where remstr is to be removed.

Example

mysql> SELECT TRIM(' trim '); 
+----------------+
| trim           | 
+----------------+
1 row in set (0.00 sec)



Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply