MySQL RTRIM Function

MySQL RTRIM function is one of the String method, 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 MySQL String RTRIM Function query to remove trailing empty spaces with an example. The basic syntax of RTRIM of a string in MySQL is as shown below:

RTRIM(String_Expression)

MySQL RTRIM Example

The MySQL 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             ');

SELECT RTRIM(' MySQL ');

SELECT RTRIM(' MySQL ') AS Result;
MySQL RTRIM Function 1

You can also achieve the same using the TRIM in the 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;
MySQL RTRIM Function 2