MySQL Reverse is one of the String Function, which is used to reverse the user specified expression (or column value). In this article we will show you, How to write MySQL String reverse Function using Command Prompt, and Workbench with example.
MySQL Reverse Syntax
The basic syntax of Reverse in MySQL is as shown below:
SELECT REVERSE (String_Expression) FROM Source
For this, we are going to use the below shown data
MySQL Reverse Example 1
The MySQL string Reverse function is used to reverse the given string. The following query will show multiple ways to use this Reverse function.
-- MySQL String Reverse Example SELECT REVERSE('Learn MySQL Server') AS `Reversed String`; SELECT REVERSE('Tutorial Gateway') AS `Reversed String`;
OUTPUT
MySQL Reverse Example 2
The string reverse function in MySQL also allows you to reverse the data inside the columns. In this example, we are going to reverse the length string data present in: Department Name, and Email column.
-- MySQL String Reverse Example 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;
OUTPUT
Thank You for Visiting Our Blog