SelectName,TRIM(Name)AS'NameWithoutSpaces'fromtest_trim;+---------------+------------------ ---+|Name&"/> SelectName,TRIM(Name)AS'NameWithoutSpaces'fromtest_trim;+---------------+------------------ ---+|Name&">
Home >Database >Mysql Tutorial >How to remove both leading and trailing spaces from a string without using MySQL LTRIM() and RTRIM() functions?
In addition to the LTRIM() and RTRIM() functions, MySQL also has the TRIM() function, which removes both leading and trailing functions from a string. The usage of TRIM() function can be understood from the following example of test_trim table whose "Name" column contains names with leading and trailing spaces.
mysql> Select Name, TRIM(Name)AS 'Name Without Spaces' from test_trim; +---------------+---------------------+ | Name | Name Without Spaces | +---------------+---------------------+ | Gaurav | Gaurav | | Rahul | Rahul | | Aarav | Aarav | +---------------+---------------------+ 3 rows in set (0.00 sec)
The above is the detailed content of How to remove both leading and trailing spaces from a string without using MySQL LTRIM() and RTRIM() functions?. For more information, please follow other related articles on the PHP Chinese website!