SQL Server Interview Question #47

What is the IN operator?

SELECT, Filtering, Sorting & Built-in Functions Mid-Level Intermediate

Detailed Explanation

IN tests whether an expression matches any value in a specified list or subquery. It often provides clearer syntax than writing many OR comparisons.

For very large or dynamic sets, a table, temporary table, table-valued parameter, or join may be more appropriate than constructing a huge literal IN list.

Code Example

SELECT Id, Name, CategoryId
FROM dbo.Products
WHERE CategoryId IN (10, 20, 30);