0
0
SQLquery~5 mins

WHERE with IN list in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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');
ASelects all products except Books and Toys
BSelects products not in Books or Toys categories
CSelects products with category NULL
DSelects products only in Books or Toys categories
Which is equivalent to WHERE id IN (1, 2, 3)?
AWHERE id = 1 AND id = 2 AND id = 3
BWHERE id NOT IN (1, 2, 3)
CWHERE id = 1 OR id = 2 OR id = 3
DWHERE id > 1 AND id < 3
What data type should the values in the IN list match?
AThe same data type as the column
BAny data type
COnly strings
DOnly numbers
What result do you get if the IN list is empty?
ANo rows returned
BAll rows returned
CError in SQL syntax
DReturns NULL values only
Which is a benefit of using WHERE ... IN over multiple OR conditions?
AIt runs slower
BIt is easier to read and write
CIt only works with numbers
DIt returns more rows
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.