Friday, December 20, 2024

MySQL REVERSE() Function

 The REVERSE() function in MySQL is used to reverse a string. It takes a string as an argument and returns a new string where the characters are in the opposite order.

Syntax:

REVERSE(string)
  • string: The string to be reversed.

Example:

SELECT REVERSE('Hello');

Output:

olleH

Example with a table:

Assume you have a table users with a column username. You can reverse the usernames like this:

SELECT username, REVERSE(username) AS reversed_username
FROM users;

This will return the username along with its reversed version.

No comments:

Post a Comment