IN Operator in SQL

Level 377 keystrokes

IN operator checks if a value matches any value in a list.

SQL code

1SELECT
-- Returns the name and country columns
2 name,
3 country
4FROM
5 users
6WHERE
-- IN keeps rows whose country is USA, Canada or Mexico
-- Same as three conditions joined with OR
7 country IN ('USA', 'Canada', 'Mexico');

Output

+-------+---------+
| name  | country |
+-------+---------+
| Alice | USA     |
| Bob   | Canada  |
| Carol | Mexico  |
+-------+---------+
3 rows in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • '× 6
  • ,× 3
  • ;× 1
  • (× 1
  • )× 1

More SQL examples at level 3

← SQL typing practice