Autumn Offers - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Concatenation
Simple text functions
Modifying strings
16. The REVERSE() function
Summary

Instruction

Nice! The next text function we'll try is REVERSE(). This takes a string as a parameter and returns its characters in reverse order.

Here we have a query that reverses the order of item names:

SELECT REVERSE(name)
FROM item;

As you can see, it's a pretty simple function to use.

Exercise

The marketing agency is organizing a costume party for all the copywriters. Each copywriter will be given a name tag with their first name spelled backward.

Let's reverse the first name of each copywriter whose ID is less than five. Show the copywriter's real first name and their "reversed" first name as the nickname column.

Stuck? Here's a hint!

You'll need this expression:

REVERSE(first_name) as nickname