Recall & Review
beginner
What does the SQL
WHERE ... IN clause do?It filters rows to include only those where a column's value matches any value in a specified list.
Click to reveal answer
beginner
Write a simple example of a
WHERE ... IN clause.SELECT * FROM employees WHERE department IN ('Sales', 'Marketing');<br>This returns employees in either Sales or Marketing departments.
Click to reveal answer
intermediate
Can the
IN list contain numbers and strings together?No, the list should contain values of the same data type as the column being filtered.
Click to reveal answer
beginner
How is
WHERE ... IN different from multiple OR conditions?WHERE column IN (a, b, c) is a shorter, clearer way to write WHERE column = a OR column = b OR column = c.Click to reveal answer
intermediate
What happens if the
IN list is empty?The query returns no rows because no value can match an empty list.
Click to reveal answer
What does this SQL do? <br>
SELECT * FROM products WHERE category IN ('Books', 'Toys');✗ Incorrect
The IN clause filters rows to those where category is either 'Books' or 'Toys'.
Which is equivalent to
WHERE id IN (1, 2, 3)?✗ Incorrect
IN with multiple values is like OR conditions for equality.
What data type should the values in the IN list match?
✗ Incorrect
Values in the IN list must match the column's data type for correct filtering.
What result do you get if the IN list is empty?
✗ Incorrect
An empty IN list matches no values, so no rows are returned.
Which is a benefit of using WHERE ... IN over multiple OR conditions?
✗ Incorrect
IN makes queries shorter and clearer compared to many OR conditions.
Explain how the WHERE ... IN clause works in SQL and give a simple example.
Think about choosing items from a list.
You got /3 concepts.
Describe the difference between using WHERE ... IN and multiple OR conditions.
Consider how you write the conditions.
You got /3 concepts.