MySQL REVERSE Function

MySQL Reverse is one of the String functions, which is useful to reverse the user-specified expression (or column value). In this article, we reveal to you how to write String reverse using Command Prompt and Workbench with example, and the basic syntax is as shown below:

SELECT REVERSE(String_Expression)
FROM Source

For this demonstration, we are going to use the below-shown data

Table 1

MySQL Reverse String Function Example

This method allows to reverse the given string and returns the output. The following query shows multiple ways to use this.

SELECT REVERSE('Learn MySQL Server') AS `ReversedString`;

SELECT REVERSE('Tutorial Gateway') AS `ReversedString`;
Example 1

MySQL also allows you to inverse the data inside the table columns. In this method example, we are going to reverse the length string data present in the Department Name and Email column.

USE mysqltutorial;
SELECT  FirstName, LastName, 
		DepartmentName, 
        REVERSE(DepartmentName) AS `Department in Reverse`,
        Email,
        REVERSE(Email) AS `Email in Reverse`
FROM employe
ORDER BY FirstName, LastName;
REVERSE Example 2