AlgoMaster Logo

Exercise: LIKE and Pattern Matching

Last Updated: May 10, 2026

1 min read

For this exercise, we will work with below data:

SQL

Exercise 1

Easy

Find all artists whose name starts with "The " (with the space). Show the name column, ordered alphabetically.

SQL

Expected Query

Expected Output

Exercise 2

Easy

Find all users whose email ends with @gmail.com. Show username and email, ordered by username.

SQL

Expected Query

Expected Output

Exercise 3

Easy

Find all artists whose name does NOT start with "The ". Show the name column, ordered alphabetically.

SQL

Expected Query

Expected Output

Exercise 4

Medium

Find all tracks whose title contains "night" case-insensitively. Show title and duration_seconds, ordered by title.

SQL

Expected Query

Expected Output

Exercise 5

Medium

Find all users whose username contains a literal underscore. Show username and email, ordered by username.

SQL

Expected Query

Expected Output

Exercise 6

Medium

Find all tracks whose title is exactly two words (contains exactly one space). Show the title, ordered alphabetically.

SQL

Expected Query

Expected Output

Exercise 7

Hard

Find all users whose username contains at least one digit. Show username and email, ordered by username.

SQL

Expected Query

Expected Output

Exercise 8

Hard

 Find all artists whose name contains either "Wave" or "Spark", but NOT both. Show the name, ordered alphabetically.

SQL

Expected Query

Expected Output

Exercise 9

Hard

Find all users whose email domain ends in .com (case-insensitive) AND whose username contains a literal underscore followed by a digit. Show username and email, ordered by username.

SQL

Expected Query

Expected Output