Informatics Practices
Answer
The TRIM()
function removes leading and trailing spaces from a given string. It performs the combined functions of LTRIM()
and RTRIM()
. The syntax is:
TRIM([{BOTH|LEADING|TRAILING} [remstr] FROM] str)
or TRM([remstr FROM] str)
.
It returns the string str
with all remstr
prefixes or suffixes removed. If none of the specifiers (BOTH, LEADING, or TRAILING) are given, BOTH is assumed. remstr
is optional, and if not specified, spaces are removed. For example,
SELECT TRIM(' Bar One ');
Output
+----------------------+
| TRIM(' Bar One ') |
+----------------------+
| Bar One |
+----------------------+