MySQL RTRIM Function

MySQL RTRIM function is one of the String methods which removes or deletes empty spaces from the right side of a user-given expression. Or say, this function removes trailing spaces from a given string.

Let me show you how to write a String RTRIM Function query to remove trailing empty spaces with an example. The basic syntax of RTRIM of a string is as shown below:


MySQL RTRIM Function Example

The string RTRIM function removes the trailing spaces or right side empty spaces from a given string and returns the remaining sentence. The following query shows multiple ways to use this one.

SELECT RTRIM('MySQL             ');


Example 1

You can also achieve the same using TRIM in MySQL. This String method example shows you how to use TRIM and RTRIM to remove the rightmost empty spaces.

SELECT RTRIM('         Tutorial Gateway         ') AS Result;

SELECT TRIM(TRAILING ' ' FROM ' Tutorial Gateway ') AS Result;

SELECT RTRIM('Tutorial Gateway ') AS Result;
RTRIM Example 2

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.