- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we eradicate leading and trailing space characters from a string in MySQL?
MySQL LTRIM() and RTRIM() functions can be used to eradicate leading and trailing spaces from a string.
MySQL LTRIM() function is used to remove the leading space characters from a string. Its syntax can be as follows −
Syntax
LTRIM(String)
Here, String, is the string, passed as an argument, whose leading space characters are to be removed.
Example
mysql> Select LTRIM(' Hello'); +--------------------+ | LTRIM(' Hello') | +--------------------+ | Hello | +--------------------+ 1 row in set (0.00 sec)
MySQL RTRIM() function is used to remove the trailing space characters from a string. Its syntax can be as follows −
Syntax
RTRIM(String)
Here, String, is the string, passed as an argument, whose trailing space characters are to be removed.
Example
mysql> Select RTRIM('Hello '); +----------------------+ | RTRIM('Hello ') | +----------------------+ | Hello | +----------------------+ 1 row in set (0.05 sec)
- Related Articles
- How to remove leading and trailing whitespace from a MySQL field value?
- Java Program to remove leading and trailing whitespace from a string
- How can I remove the leading and trailing spaces both at once from a string by using MySQL LTRIM() and RTRIM() functions?
- How can I remove the leading and trailing spaces both at once from a string without using MySQL LTRIM() and RTRIM() functions?
- How to remove white spaces (leading and trailing) from string value in MongoDB?
- Java Program to remove the leading and trailing quotes from a string
- How to remove leading and trailing whitespace in a MySQL field?
- How can I eradicate some specific suffix or prefix or both from a MySQL string?
- Trim (Remove leading and trailing spaces) a string in C#
- Trim a string in Java to remove leading and trailing spaces
- Remove newline, space and tab characters from a string in Java
- How can we extract a substring from a string in MySQL?
- For each element in a Numpy array, return a copy with the leading and trailing characters removed
- How can we escape special characters in MySQL statement?
- Python Pandas – Remove leading and trailing whitespace from more than one column

Advertisements