Recall & Review
beginner
What does the NOT operator do in a SQL WHERE clause?
The NOT operator reverses the condition in the WHERE clause. It selects rows where the condition is false.
Click to reveal answer
beginner
Write a SQL query to select all employees who are NOT in the 'Sales' department.
SELECT * FROM employees WHERE NOT department = 'Sales';
Click to reveal answer
intermediate
Can the NOT operator be combined with other conditions in the WHERE clause?
Yes, NOT can be combined with AND, OR, and parentheses to create complex conditions.
Click to reveal answer
advanced
How does NOT work with NULL values in SQL WHERE clauses?
NOT with NULL returns UNKNOWN, so rows with NULL in the condition are not selected unless IS NULL or IS NOT NULL is used.
Click to reveal answer
intermediate
Rewrite this query using NOT: SELECT * FROM products WHERE category <> 'Books';
SELECT * FROM products WHERE NOT category = 'Books';
Click to reveal answer
What does this query return? SELECT * FROM users WHERE NOT active = 1;
✗ Incorrect
NOT active = 1 means selecting users where active is not 1, so users who are not active.
Which is equivalent to: WHERE NOT (age > 30)?
✗ Incorrect
NOT (age > 30) means age is less than or equal to 30.
What happens if you use NOT with a NULL value in a condition?
✗ Incorrect
NOT with NULL results in UNKNOWN, so the row is not selected.
How to select rows where status is NOT 'completed' or 'pending'?
✗ Incorrect
NOT applies to the whole condition inside parentheses to exclude both 'completed' and 'pending'.
Which query uses NOT correctly to exclude 'admin' users?
✗ Incorrect
NOT role = 'admin' and role != 'admin' both select users whose role is not 'admin'.
Explain how the NOT operator changes the meaning of a condition in a SQL WHERE clause.
Think about what happens when you say NOT true or NOT false.
You got /3 concepts.
Describe how to combine NOT with other conditions to filter data in SQL.
Consider how NOT affects multiple conditions together.
You got /4 concepts.