MariaDB REVERSE() Function

In MariaDB, REVERSE() is a built-in string function that reverses the given string and returns it.

MariaDB REVERSE() Syntax

Here is the syntax of the MariaDB REVERSE() function:

REVERSE(str)

Parameters

str

Required. The string to reverse.

If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1.

Return value

The MariaDB REVERSE() function returns the reversed string.

If the argument is NULL, the REVERSE() function will return NULL.

MariaDB REVERSE() Examples

This statement shows the basic usage of the MariaDB REVERSE() function:

SELECT
    REVERSE('ABC'),
    REVERSE('123');

output

+----------------+----------------+
| REVERSE('ABC') | REVERSE('123') |
+----------------+----------------+
| CBA            | 321            |
+----------------+----------------+

Conclusion

In MariaDB, REVERSE() is a built-in string function that reverses the given string and returns it.