Reverse String Function In Sql in SQL
? REVERSE Function in SQL
The REVERSE() function in SQL is used to reverse the characters in a string.
? Syntax:
REVERSE(string)string: The string you want to reverse.
? Example 1: Reverse a simple word
SELECT REVERSE('SQL') AS reversed;? Output:
| reversed |
|---|
| LQS |
? Example 2: Reverse a sentence
SELECT REVERSE('Hello World') AS reversed;? Output:
| reversed |
|---|
| dlroW olleH |
? Example 3: Reverse a number (stored as string)
SELECT REVERSE('12345') AS reversed;? Output:
| reversed |
|---|
| 54321 |
? Supported In:
MySQL
SQL Server
PostgreSQL (via
reverse()function)Oracle (use
REVERSE()via custom function)
? Use Case Examples:
Palindrome checks
String transformations
Text pattern analysis
Would you like to see how to reverse each word in a sentence individually using SQL logic?