WHERE Clause & Filtering SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Select Employees for Role Mapping

Find employees assigned to either IT_PROG or HR_REP.

  • Filtering

Exercise brief

Understand the request

Workforce planner A role-mapping review is limited to the programmer and HR representative job families.

Return employees assigned either the IT_PROG or HR_REP job code.

Return

  • Return first_name, last_name, job_id in this exact left-to-right order.

Constraints

  • Use a single membership predicate for both exact job codes.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

employees

  • first_nameVARCHAR(50)
  • last_nameVARCHAR(50)
  • job_idVARCHAR(20)

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

A membership predicate is clearer than repeating the same column in multiple OR conditions.

Hint 2

Place both quoted job codes inside one parenthesized IN list.

Hint 3

SELECT first_name, last_name, job_id FROM employees WHERE job_id IN (/* approved job codes */);

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT first_name, last_name, job_id FROM employees WHERE job_id IN ('IT_PROG', 'HR_REP');

Why this works

IN keeps a row when job_id equals any value in the approved list and is equivalent to two OR-connected equalities. Duplicate values in the list do not duplicate result rows, while a NULL job_id does not match the list. Inline IN lists work consistently across the supported engines; dynamic membership normally comes from a subquery or joined table.

Success check

Every returned employee has one of the two approved job codes.

Expected result

Use this output to verify values, aliases, ordering, and row count.

first_namelast_namejob_id
JohnDoeIT_PROG
JaneSmithHR_REP
MikeJohnsonIT_PROG
DavidBrownIT_PROG
LisaDavisHR_REP
AmyTaylorIT_PROG
EmmaThomasHR_REP

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.