
- 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 we use the output of LTRIM() and RTRIM() functions to update MySQL table?
We can use LTRIM() and RTRIM functions with MySQL update clause so that the values, after removing space characters, in the table can be updated. Following examples will demonstrate it −
Example
Suppose we know that there can be some space characters in the values of ‘Name’ column of table ‘Student’ then with the help of following single query we can remove the space characters from that column’s value and also update the table −
mysql> Update Student SET Name = LTRIM(Name); Query OK, 0 rows affected (0.07 sec) Rows matched: 5 Changed: 0 Warnings: 0 mysql> Update Student SET Name = RTRIM(Name); Query OK, 0 rows affected (0.00 sec) Rows matched: 5 Changed: 0 Warnings: 0
- Related Articles
- How MySQL LTRIM() and RTRIM()functions can be used with WHERE clause?
- 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 can we use MySQL TRIM() to remove the whitespaces from all the rows and update table?
- How can we update any value in MySQL view as we can update the values in MySQL table?
- How can we update values in a MySQL table?
- How can we use LPAD() or RPAD() functions with the values in the column of a MySQL table?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- Can we perform MySQL UPDATE and change nothing in a table?
- How can we get the sorted MySQL output?
- How can we insert values into a table with the help of MySQL self-computed output?
- How can we fetch a particular row as output from a MySQL table?
- How can we update MySQL table after padding a string with the values of the column?
- What MySQL functions can we use to change the character case of a string?
- How can we update MySQL table after removing a particular string from the values of column?

Advertisements