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 a String reverse function using Command Prompt and Workbench with an 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 of 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`;
MySQL REVERSE Function 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;
MySQL REVERSE Function Example 2