Skip to main contentSkip to solution

What is this query used for?

SELECT * FROM Employee WHERE DeptID NOT IN ('D01', 'D02', 'D06');

Solution

✅ Correct Option: 2

NOT IN returns a row only when its DeptID is not in the given list. So the query selects every employee whose department is not D01, D02 or D06, and SELECT * returns all columns for those employees.


Option 1: this describes IN, which is the opposite of NOT IN.

Option 4: a single row has only one DeptID, so no employee can belong to all three departments at once. Also, IN works as an OR over the list, not an AND.

NOT IN is shorthand for DeptID <> 'D01' AND DeptID <> 'D02' AND DeptID <> 'D06'.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question