SQL IN

Match any value in a list.

✍️ 3 exercises + code challenge in this lesson

IN is a shorthand for several OR conditions:

WHERE Country IN ('UAE', 'UK', 'Canada')

NOT IN excludes the values. IN also accepts a subquery: WHERE CustomerID IN (SELECT CustomerID FROM Orders).

Key Takeaways: SQL IN

Mastering SQL IN helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL IN Code Example

SQL
SELECT CustomerName, Country FROM Customers
WHERE Country IN ('UAE', 'UK', 'Canada');

-- Customers who have placed at least one order
SELECT CustomerName FROM Customers
WHERE CustomerID IN (SELECT CustomerID FROM Orders);
Free sign-in required · Google login available

SQL IN Practice Exercises

Check what you learned in “SQL IN”.

/ 3 solved
Fill in the blank

Match any of several cities.

WHERE City  ('Lahore', 'Karachi')
✓ Correct! Not quite. Try again.
Multiple choice

IN is a shorthand for multiple…

✓ Correct! Not quite. Try again.
Code challenge

Select CustomerName of customers in 'UK' or 'Canada'.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services