🔧 Quick Syntax
SELECT column1, column2
FROM table_name
WHERE column_name IN (value1, value2, value3);
This is how you tell SQL:
“Only give me rows where this column matches one of these specific values.”
It’s like using a short list instead of writing out a bunch of ORs.
🧾 Here’s the Table You’re Working With
Let’s say your table is called customers
:
id | name | city | plan |
---|---|---|---|
1 | Fenn Rask | Fogtown | trial |
2 | Milo Kresh | Dustvale | pro |
3 | Sora Dune | Cloudhill | free |
4 | Tovi Glint | Windmere | pro |
5 | Lexa Vohn | Fogtown | basic |
6 | Kye Trinn | Dustvale | trial |
✅ Suppose You Want Customers from Fogtown or Windmere
SELECT name, city
FROM customers
WHERE city IN ('Fogtown', 'Windmere');
💡 Output:
Fenn Rask Fogtown
Lexa Vohn Fogtown
Tovi Glint Windmere
SQL checked the city
column and gave you only the rows where the value is either ‘Fogtown’ or ‘Windmere’.
✅ Suppose You Want Users on Trial or Basic Plans
SELECT name, plan
FROM customers
WHERE plan IN ('trial', 'basic');
💡 Output:
Fenn Rask trial
Lexa Vohn basic
Kye Trinn trial
This pulled all users whose plan
is either ‘trial’ or ‘basic’. Way cleaner than writing ORs.
✅ IN Works with Numbers Too
Let’s say you’re looking for customers with IDs 1, 4, and 6:
SELECT name, id
FROM customers
WHERE id IN (1, 4, 6);
💡 Output:
Fenn Rask 1
Tovi Glint 4
Kye Trinn 6
IN
works just fine with numbers too. Handy when filtering a set of known values.
🧃 Recap – What You Learned
IN
filters for specific values in a list- Works with text, numbers, dates, and more
- Much cleaner than writing
OR
over and over - Great for targeting exact matches quickly and clearly