Function Reference

REVERSE

Reverses a string.

MySQL 8.1
REVERSE(str)

Parameters

strVARCHAR
Source string

Return value

A string with the characters in reverse order

Examples

Word written backwards

MySQL 8.1
SELECT REVERSE('drawer');
REVERSE('drawer')
reward

Palindrome check

MySQL 8.1
SELECT word,
	word = REVERSE(word) AS is_palindrome
FROM (
		SELECT 'level' AS word
		UNION ALL
		SELECT 'drawer'
	) AS words;
wordis_palindrome
level1
drawer0

Details

Characters are reordered, not bytes, so Cyrillic is reversed correctly. Comparing a string with its reversed copy — word = REVERSE(word) — checks whether a word reads the same in both directions.

See also