mode helix
NEWIntroducing Helix—the first instant, responsive data engine.Learn more

SQL IN

Starting here? This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.

The SQL IN operator

IN is a logical operator in SQL that allows you to specify a list of values that you'd like to include in the results. For example, the following query of data from the Billboard Music Charts will return results for which the year_rank column is equal to one of the values in the list:

SELECT *
  FROM tutorial.billboard_top_100_year_end
 WHERE year_rank IN (1, 2, 3)

As with comparison operators, you can use non-numerical values, but they need to go inside single quotes. Regardless of the data type, the values in the list must be separated by commas. Here's another example:

SELECT *
  FROM tutorial.billboard_top_100_year_end
 WHERE artist IN ('Taylor Swift', 'Usher', 'Ludacris')

Sharpen your SQL skills

Practice Problem

Write a query that shows all of the entries for Elvis and M.C. Hammer.

Hint: M.C. Hammer is actually on the list under multiple names, so you may need to first write a query to figure out exactly how M.C. Hammer is listed. You're likely to face similar problems that require some exploration in many real-life scenarios.

Try it out See the answer

Next Lesson

SQL BETWEEN

Looks like you've got a thing for cutting-edge data news.

Get the latest.

Get started