
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can I remove the leading and trailing spaces both at once from a string without using MySQL LTRIM() and RTRIM() functions?
Other than LTRIM() and RTRIM() functions, MySQL has TRIM() function to remove leading and trailing function both at once from a string. The use of TRIM() function can be understood from the following example of a test_trim table which has a column ‘Name’ containing the 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)
- Related Articles
- How can I remove the leading and trailing spaces both at once from a string by using MySQL LTRIM() and RTRIM() functions?
- Trim (Remove leading and trailing spaces) a string in C#
- How to remove white spaces (leading and trailing) from string value in MongoDB?
- How MySQL LTRIM() and RTRIM()functions can be used with WHERE clause?
- Trim a string in Java to remove leading and trailing spaces
- How can we use the output of LTRIM() and RTRIM() functions to update MySQL table?
- How to remove leading and trailing whitespace from a MySQL field value?
- How can we eradicate leading and trailing space characters from a string in MySQL?
- Java Program to remove leading and trailing whitespace from a string
- Java Program to remove the leading and trailing quotes from a string
- How to remove leading and trailing whitespace in a MySQL field?
- MySQL query to remove trailing spaces
- Python Pandas – Remove leading and trailing whitespace from more than one column
- How to remove double or more spaces from a string in MySQL?
- C++ program to remove spaces from a string using String stream

Advertisements