
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Eradicate Leading and Trailing Spaces 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)
Advertisements