Learn

LIKE can be a useful operator when you want to compare similar values.

The movies table contains two films with similar titles, ‘Se7en’ and ‘Seven’.

How could we select all movies that start with ‘Se’ and end with ‘en’ and have exactly one character in the middle?

SELECT * FROM movies WHERE name LIKE 'Se_en';
  • LIKE is a special operator used with the WHERE clause to search for a specific pattern in a column.

  • name LIKE 'Se_en' is a condition evaluating the name column for a specific pattern.

  • Se_en represents a pattern with a wildcard character.

The _ means you can substitute any individual character here without breaking the pattern. The names Seven and Se7en both match this pattern.

Instructions

1.

Let’s test it out.

In the code editor, type:

SELECT * FROM movies WHERE name LIKE 'Se_en';

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?