What is the purpose of the AND operator in a WHERE clause?
A
To combine multiple tables B
To specify that all conditions must be true C
To sort query results D
To group rows by columns
Analysis & Theory
AND combines multiple conditions; all must be true for a row to match.
Which operator would you use to return rows where at least one condition is true?
A
AND B
OR C
NOT D
IN
Analysis & Theory
OR returns rows if any condition evaluates to true.
How do you select customers from 'USA' who have a balance greater than 1000?
A
WHERE country = 'USA' OR balance > 1000 B
WHERE country = 'USA' AND balance > 1000 C
WHERE country = 'USA' NOT balance > 1000 D
WHERE country = 'USA' XOR balance > 1000
Analysis & Theory
AND requires both conditions to be true.
What does the NOT operator do?
A
It makes all conditions true B
It inverts the result of a condition C
It combines conditions together D
It sorts the results in descending order
Analysis & Theory
NOT negates a condition, selecting rows where the condition is false.
Which query selects orders not placed in January?
A
WHERE NOT month = 'January' B
WHERE month <> 'January' C
WHERE month != 'January' D
All of the above
Analysis & Theory
All options correctly filter out rows where month is 'January'.
How do you find employees who are in 'Sales' or 'Marketing'?
A
WHERE department = 'Sales' AND department = 'Marketing' B
WHERE department = 'Sales' OR department = 'Marketing' C
WHERE department IN ('Sales' AND 'Marketing') D
WHERE department NOT IN ('Sales', 'Marketing')
Analysis & Theory
OR allows either condition to match.
Which of the following is equivalent to 'NOT (salary > 5000)'?
A
salary >= 5000 B
salary <= 5000 C
salary < 5000 D
salary != 5000
Analysis & Theory
NOT (salary > 5000) means salary <= 5000, but more precisely salary <= 5000; however, many use < 5000 as the next smaller condition.
Which query selects products that are in stock and have a price less than 100?
A
WHERE in_stock = TRUE OR price < 100 B
WHERE in_stock = TRUE AND price < 100 C
WHERE NOT in_stock AND price < 100 D
WHERE in_stock = TRUE NOT price < 100
Analysis & Theory
AND ensures both conditions are met.
What does this query return?
SELECT * FROM customers WHERE NOT country = 'Canada';
A
Only customers from Canada B
All customers except those from Canada C
Customers where country is NULL D
No rows
Analysis & Theory
NOT negates the condition, excluding 'Canada'.
Which query selects records where age is over 18 and less than 65?
A
WHERE age > 18 OR age < 65 B
WHERE age BETWEEN 18 AND 65 C
WHERE age > 18 AND age < 65 D
WHERE NOT age > 65
Analysis & Theory
AND requires both conditions (greater than 18 and less than 65) to be true.