Home >Database >Mysql Tutorial >How can we eliminate leading and trailing space characters from strings in MySQL?
MySQL LTRIM() and RTRIM() functions can be used to eliminate leading and trailing spaces from strings.
MySQL LTRIM() function is used to remove leading space characters from a string. Its syntax is as follows -
LTRIM(String)
Here, String is the string passed as parameter and its leading space characters will be removed.
mysql> Select LTRIM(' Hello'); +--------------------+ | LTRIM(' Hello') | +--------------------+ | Hello | +--------------------+ 1 row in set (0.00 sec)
The MySQL RTRIM() function is used to remove trailing space characters from a string. Its syntax is as follows -
RTRIM(String)
Here, String is the string passed as parameter and its trailing space characters will be removed.
mysql> Select RTRIM('Hello '); +----------------------+ | RTRIM('Hello ') | +----------------------+ | Hello | +----------------------+ 1 row in set (0.05 sec)
The above is the detailed content of How can we eliminate leading and trailing space characters from strings in MySQL?. For more information, please follow other related articles on the PHP Chinese website!