Recall & Review
beginner
What does the AND operator do in a SQL WHERE clause?
The AND operator combines two conditions and returns true only if both conditions are true.
Click to reveal answer
beginner
How does the OR operator work in SQL?
The OR operator returns true if at least one of the combined conditions is true.
Click to reveal answer
beginner
Explain the NOT operator in SQL.
The NOT operator reverses the result of a condition. If the condition is true, NOT makes it false, and vice versa.
Click to reveal answer
intermediate
Write a SQL query using AND and OR to find employees who are in department 10 and have a salary over 5000 or are in department 20.
SELECT * FROM employees WHERE (department_id = 10 AND salary > 5000) OR department_id = 20;
Click to reveal answer
intermediate
Why is it important to use parentheses when combining AND and OR in SQL?
Parentheses control the order of evaluation, ensuring the query logic works as intended by grouping conditions properly.
Click to reveal answer
Which SQL operator returns true only if both conditions are true?
✗ Incorrect
AND returns true only when both conditions are true.
What does the OR operator do in SQL?
✗ Incorrect
OR returns true if at least one condition is true.
How does the NOT operator affect a condition?
✗ Incorrect
NOT reverses the result of a condition.
Which query correctly finds rows where age is over 30 AND city is 'New York'?
✗ Incorrect
AND requires both conditions to be true.
Why use parentheses in a WHERE clause with AND and OR?
✗ Incorrect
Parentheses group conditions to control how SQL evaluates them.
Describe how AND, OR, and NOT logical operators work in SQL WHERE clauses.
Think about how these operators combine or change conditions.
You got /3 concepts.
Explain why parentheses are important when using AND and OR together in SQL queries.
Consider how math uses parentheses to clarify operations.
You got /3 concepts.