Contents
SQL IN Operator Introduced
In SQL, IN
is a logical operator that allows you to filter a set of values against a specific condition. It is usually used with the WHERE clause.
In the parentheses, you can define the exact values you need to be matched by the data entries:
SELECT column_demo(z)
FROM table_demo
WHERE column_demo IN (value1, value2, ...);
You can also use the SELECT statement to create a subquery that returns a list of values in a specified column:
SELECT column_demo(z)
FROM table_demo
WHERE column_demo IN (SELECT STATEMENT);
Demo Databases
In this tutorial, we will be using two demo tables for our data – Developers and Customers.
Developers
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
6 | Basma Zlata | Miami | USA |

- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid certificates of completion

- Professional service
- Flexible timetables
- A variety of features to choose from
- Professional certificates of completion
- University-level courses
- Multiple Online degree programs

- Great user experience
- Offers quality content
- Very transparent with their pricing
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
Customers
id | name | contact | address | city | postal_code | country |
---|---|---|---|---|---|---|
1 | Ben Choplinks | Ben Choplink | Obeesre Str. 51 | Rome | 11207 | Italy |
2 | Donald Rich | Donald Richario | Avda. de la Confgfstitución 4122 | Tallin | 17021 | Estonia |
3 | Lilly Smilkins | Lilly Smilkin | Matadsderos 2312 | Eguero | 14023 | Mexico |
4 | Brandinina | Tom Hitchins | 110 Hanegover Sq. | London | WB2 2DP | UK |
5 | Carizmos | Christiano Kerrys | Berguvsesvägen 9 | Lulea | S-968 43 | Sweden |
Examples of Using SQL IN()
The example below picks all the developers from USA, France and India:
For an opposite result, you can also use the NOT IN
operator in SQL. The code in this next example picks out only the developers who are not from those countries:
Working with IN() in Multiple Tables
In the last example, we will try something a bit more complicated. The code you can see below uses both of our demo tables to pick all the developers whose countries match those of the customers:
Instead of specifying the values for SQL IN()
, we include SELECT Country FROM Customers
within the parentheses. This means the SELECT statement will take the values from the Country
column in the Customers
table.
Latest Udacity Coupon Found:
75% OFF COURSES
Udacity Black Friday Offer
The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!