Consider the following table structures related to a university for the below…
2020
Consider the following table structures related to a university for the below question

On the basis of above given table structures, retrieve the distinct employee ID (EMPID) of all employees of university who are working on project. No. 20,30 and 40.
- A.
SELECT EMPID FROM PROJECTWORK WHERE PROJNO=(20,30,40);
- B.
SELECT EMPID FROM PROJECTWORK WHERE PROJNO IN (20,30,40);
- C.
SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO IN(20,30,40);
- D.
SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO=20,30,40;
Attempted by 387 students.
Show answer & explanation
Correct answer: C
Correct query: SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO IN (20,30,40);
Explanation: Use IN to match any of the listed project numbers, and use DISTINCT to ensure each employee ID appears only once even if an employee works on multiple of those projects.
IN vs equals: WHERE PROJNO IN (20,30,40) matches any of the values. Using = with a parenthesized list or comma-separated values is invalid SQL.
DISTINCT: SELECT DISTINCT EMPID removes duplicate EMPIDs when an employee is assigned to more than one of the specified projects.
Alternative: you can also write the same logic using OR conditions: SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO = 20 OR PROJNO = 30 OR PROJNO = 40;
Result note: The query returns the unique EMPID values of employees who work on project numbers 20, 30, or 40.
A video solution is available for this question — log in and enroll to watch it.