×

MySQL REVERSE() function

In this context, we will learn how we can use the MySQL REVERSE() function with proper syntax and good examples.

Introduction of MySQL REVERSE() function

This function could be used to reverse a string and find the result. The REVERSE() function takes the input parameter as a string and results in the reverse order of that string.

Syntax of the MySQL REVERSE() function

The syntax of the MySQL REVERSE() function is given as follows:

SELECT REVERSE(string)

Parameters or arguments used in MySQL REVERSE() function:

There is only one parameter accepted by the REVERSE() function in MySQL, which is given as follows:

String- It is the string that will be reversed.

Returns:

It will return a string to find a string.

Application used for REVERSE() function:

The REVERSE() function can be used in the given below MySQL versions.:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1
  • MySQL 4.0
  • MySQL 3.23

Examples of MySQL REVERSE() function:

Now we will look into some MySQL REVERSE() function examples and will explore how we can use the REVERSE function in MySQL.

Example-1:

We will use the REVERSE function in this example to reverse a string.

SELECT REVERSE("JTP");

Output:

REVERSE(“JTP”)
PTJ
1 row in set (0.00 sec)

Example-2:

We will use the REVERSE function in this example to reverse a string.

SELECT REVERSE("JAVATPOINT");

Output:

REVERSE(“JAVATPOINT”);
TNIOPTAVAJ
1 row in set (0.00 sec)

Example-3:

In this example, we will use the REVERSE function to reverse a sentence :

SELECT REVERSE("JAVATPOINT is an interesting site");

Output:

REVERSE(“JAVATPOINT is an interesting site”)
etis gnitseretni na si TNIOPTAVAJ
1 row in set (0.00 sec)

Example-4:

Now we will use the REVERSE() function to find if a string is a Palindrome :

DECLARE
@input VARCHAR(100) = 'madam';
SELECT
CASE
WHEN @input = REVERSE(@input)
THEN 'Palindrome'
ELSE 'Not Palindrome'
END result;

Output:

result
Palindrome
1 row in set (0.00 sec)

Application of MySQL REVERSE() function:

This function is used to reverse a string and find the result.

Summary:

In the above context, we have learned how we can use the REVERSE() function in MySQL used to reverse a string and find the result.


Related Topics

MySQL Invisible Index

Invisible Index MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in...

3 minutes read.

MySQL vs SQL

What is MySQL? The open-source MySQL relational database management system is a vital software component for web-based applications. As the data is saved and sent over the internet, databases and related...

6 minutes read.

MySQL NATURAL JOIN

The natural join combines multiple tables using a column with the same name and data type. This operation combines a row of the two tables using common columns. This join...

4 minutes read.

MySQL LENGTH() Function

In this context, we will learn how we can use the MySQL LENGTH() function with proper syntax and good examples. Introduction of MySQL LENGTH() function This function in MySQL is used to...

2 minutes read.

MySQL MIN function

The MIN() function determines the minimum or lowest value of the data set. This function works on numerical data type values. If the table displays zero value, then the row...

4 minutes read.

MySQL DATEDIFF() function

In this context, we will learn how we can use the MySQL DATEDIFF() function with proper syntax and good examples. Introduction of MySQL DATEDIFF() function DATEDIFF() function in MySQL is used to...

3 minutes read.

MySQL LOAD_FILE() function

In this context, we will learn how we can use the MySQL LOAD_FILE() function with proper syntax and good examples. Introduction of MySQL LOAD_FILE() function The LOAD_FILE() function in MySQL reads a...

3 minutes read.

MySQL QUARTER() function

In this context, we will learn how we can use the MySQL QUARTER() function with proper syntax and good examples. Introduction of MySQL QUARTER() function The QUARTER() function in MySQL returns the...

3 minutes read.

MySQL TAN() Function

Basically, the TAN() function in MySQL is used to give back the tangent of a mentioned number.In any kind of right-angle triangle, the tangent of an angle is the length...

2 minutes read.

MySQL LEAST function

This statement displays the smallest value of the table. The LEAST function returns a null value when the table contains a null value. If the table contains all numerical values,...

2 minutes read.

MySQL Data Types

Introduction of the Data types In the data file, we have several information such as names, numbers, marks, and other information. This information specifies categories such as numbers, characters, and decimal...

8 minutes read.

MySQL REVERSE() function

In this context, we will learn how we can use the MySQL REVERSE() function with proper syntax and good examples. Introduction of MySQL REVERSE() function This function could be used to reverse...

2 minutes read.

MySQL PERIOD_ADD() function

In this context, we will learn how we can use the MySQL PERIOD_ADD() function with proper syntax and good examples. Introduction of MySQL PERIOD_ADD() function In MySQL, PERIOD_ADD() function will help to...

2 minutes read.

MySQL Union

MySQL contains the same categories of data in a different table. Sometimes, you require multiple tables to collect data together. MySQL union is a function to combine two table's data...

5 minutes read.

MySQL Date and Time function

The date function displays day, year, month, time, and current date. It shows the date and time as per the requirement of the applications. The data either store on the...

8 minutes read.

MySQL Queries

MySQL Queries MySQL supports SQL queries in the MySQL interface. These queries help to interact data with the application. MySQL uses create database, user database, create a table, truncate table, and...

13 minutes read.

MySQL INSTR() Function

In this context, we will learn how we can use the MySQL INSTR() function with proper syntax and good examples. Introduction of MySQL INSTR() function This function in MySQL returns the location...

4 minutes read.

MySQL LN() function

In this context, we will learn how we can use the MySQL LN() function with proper syntax and good examples. Introduction of MySQL LN() function For evaluation of the natural logarithm of...

2 minutes read.

MySQL Database Introduction

MySQL - Database Introduction: The database plays an essential role in MySQL for storing and modifying the data. The database creates and keeps multiple tables. The database organizes and manipulates...

8 minutes read.

MySQL FROM_BASE64() function

In this context, we will learn how we can use the MySQL FROM_BASE64()() function with proper syntax and good examples. Introduction of MySQL FROM_BASE64()() function Basically, the FROM_BASE64() function In MySQL decodes...

2 minutes read.