Home > Database > Mysql Tutorial > How to remove both leading and trailing spaces from a string without using MySQL LTRIM() and RTRIM() functions?

How to remove both leading and trailing spaces from a string without using MySQL LTRIM() and RTRIM() functions?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-08-28 13:35:18
forward
1599 people have browsed it

如何在不使用 MySQL LTRIM() 和 RTRIM() 函数的情况下同时从字符串中删除前导空格和尾随空格?

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.

Example

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template