IN and NOT IN
We can apply slightly more complex filters using the
NOT IN clauses, which are especially useful when you want to filter using a list of values.
For example, if we wanted to find all the students in classes 7A, 7B and 8A, we could write the following:
WHERE class IN ('7A', '7B', '8A')
Or, if we wanted to find all the students who are not in class 7A or 7B, we could write:
WHERE class NOT IN ('7A', '7B')
NOT IN clause is the negation of the
IN clause. It retrieves rows where the specified column's value does not match any value in the list.
Now it's your turn! Open the following questions in a new tab to try out the
NOT IN operators: