Home > Database > Mysql Tutorial > How to use the TRIM() function in MySQL

How to use the TRIM() function in MySQL

WBOY
Release: 2023-05-26 13:02:15
forward
3517 people have browsed it

TRIM()

TRIM([remstr FROM] str)The function is used to return the substring after deleting all remstr strings on both sides of the string str. Remstr defaults to spaces. For example:

SELECT TRIM('  MySQL字符串函数  ') AS str1,
       TRIM('-' FROM '--MySQL字符串函数--') AS str2;
str1          |str2          |
--------------+--------------+
MySQL字符串函数|MySQL字符串函数|
Copy after login

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) function is used to return all remstr on both sides/left/right of the deleted string str The substring after the string, the strings on both sides (BOTH) are deleted by default, and remstr defaults to spaces. For example:

SELECT TRIM(LEADING ' ' FROM '  MySQL字符串函数  ') AS str1,
       TRIM(TRAILING '-' FROM '--MySQL字符串函数--') AS str2;
str1            |str2            |
----------------+----------------+
MySQL字符串函数  |--MySQL字符串函数|
Copy after login

The above is the detailed content of How to use the TRIM() function in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.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