Example 1
Return only employees who match specific (department, level) combinations
The filter targets two combinations: Engineering at level 3, and Sales at level 2. Alice matches Engineering/3. Carol matches Sales/2. Bob is Engineering/2 — that combination is not in the list. Dave is Sales/1 — also not in the list. Eve is HR/3 — not in the list. Using (department, level) IN (('Engineering', 3), ('Sales', 2)) is equivalent to the SQL Server expansion (department = 'Engineering' AND level = 3) OR (department = 'Sales' AND level = 2) and both return the same two rows. The key distinction from two separate IN lists is that department IN ('Engineering', 'Sales') AND level IN (3, 2) would produce four combinations including Engineering/2 and Sales/3, which are not the intended targets.
CREATE TABLE employees (
id INT,
name VARCHAR(20),
department VARCHAR(20),
level INT
);
INSERT INTO
employees
VALUES
(1, 'Alice', 'Engineering', 3),
(2, 'Bob', 'Engineering', 2),
(3, 'Carol', 'Sales', 2),
(4, 'Dave', 'Sales', 1),
(5, 'Eve', 'HR', 3);SELECT
id,
name,
department,
level
FROM
employees
WHERE
(department, level) IN (('Engineering', 3), ('Sales', 2))
ORDER BY
id;| id | name | department | level |
|---|---|---|---|
| 1 | Alice | Engineering | 3 |
| 3 | Carol | Sales | 2 |
CREATE TABLE employees (
id INT,
name VARCHAR(20),
department VARCHAR(20),
level INT
);
INSERT INTO
employees
VALUES
(1, 'Alice', 'Engineering', 3),
(2, 'Bob', 'Engineering', 2),
(3, 'Carol', 'Sales', 2),
(4, 'Dave', 'Sales', 1),
(5, 'Eve', 'HR', 3);SELECT
id,
name,
department,
level
FROM
employees
WHERE
(
department = 'Engineering'
AND level = 3
)
OR (
department = 'Sales'
AND level = 2
)
ORDER BY
id;| id | name | department | level |
|---|---|---|---|
| 1 | Alice | Engineering | 3 |
| 3 | Carol | Sales | 2 |
MySQL, MariaDB, PostgreSQL, and SQLite use (department, level) IN (('Engineering', 3), ('Sales', 2)). SQL Server expands the pairs into explicit AND/OR conditions. All engines return the same two rows.