TRIM (remove lead or trail chars.)
The TRIM function removes leading characters, trailing characters, or both from a character string or BLOB value.
If a removal character is not specified, spaces are removed by default. TRIM will not remove characters within a string. The COLLATE clause forces the result set into another pre-existing collating sequence.
Format:
TRIM([[{LEADING|TRAILING BOTH}] [remove_char] FROM source_string [COLLATE name])
Example:
TRIM(LEADING 'My name is ' FROM 'My name is William Diamond') Result: 'William Diamond'
TRIM(BOTH '---' FROM '---One Thousand Dollars---') Result: 'One Thousand Dollars'
TRIM(TRAILING 'Dollars---' FROM '---One Thousand Dollars---') Result: '---One Thousand '
> MySQL, Oracle, and PostgreSQL support TRIM.
> The Access functions, TRIM(string), LTRIM(string), and RTRIM(string) are non-standard according to
ANSI standards.
> DB2 and SQL Server do not support TRIM. Instead they have LTRIM(string) and RTRIM(string).
> Oracle and PostgreSQL also have LPAD and RPAD to add spaces.