Difficulty: Easy
Correct Answer: Both IN and NOT IN.
Explanation:
Introduction / Context:
As SQL predicates become longer, readability and correctness suffer. A classic case is when you need to check whether a column's value belongs to several alternatives, or explicitly does not belong to them. Instead of chaining many OR or AND comparisons, SQL provides concise list-membership operators that make intent obvious and reduce mistakes.
Given Data / Assumptions:
Concept / Approach:
Use IN to replace a chain of OR equality tests, and use NOT IN to replace a chain of AND inequality tests. These operators express set membership and non-membership directly, improving clarity and aiding optimizers in some systems. They are ideal when comparing a single expression against a list of constants or a subquery result set.
Step-by-Step Solution:
Verification / Alternative check:
Most vendor style guides recommend IN/NOT IN for readability and correctness when evaluating membership, and many show measurable simplification in code reviews and query linting tools.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
Both IN and NOT IN.
Discussion & Comments