Syntax of TRIM():
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)
For example:
SELECT TRIM(' bar ');
will return ‘bar’ (spaces dropped).
SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx');
will return ‘barxxx’ (only leading x characters is removed).
SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');
will return ‘bar’ (leading and trailing xs is dropped).
SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
will return ‘barx’ (trailing xyz is cleared).
This function is multi-byte safe. And it can also be used with other SQL command such as UPDATE to perform modification update directly on database table data with SQL statements using tool such as phpMyAdmin.