0
0
SQLquery~5 mins

WHERE with AND operator in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the WHERE clause do in SQL?
The WHERE clause filters rows in a table to return only those that meet a specified condition.
Click to reveal answer
beginner
How does the AND operator work in a WHERE clause?
The AND operator combines two or more conditions and returns rows only if all conditions are true.
Click to reveal answer
beginner
Write a simple SQL query using WHERE with AND to find employees older than 30 and in the 'Sales' department.
SELECT * FROM employees WHERE age > 30 AND department = 'Sales';
Click to reveal answer
intermediate
Can the AND operator be used with more than two conditions in a WHERE clause?
Yes, you can combine multiple conditions with AND. All must be true for a row to be included.
Click to reveal answer
beginner
What happens if one condition in a WHERE clause with AND is false?
The entire WHERE condition is false, so the row is excluded from the results.
Click to reveal answer
What does the AND operator do in a SQL WHERE clause?
AReturns rows where any condition is true
BReturns all rows regardless of conditions
CReturns rows where no condition is true
DReturns rows where all conditions are true
Which SQL query correctly uses WHERE with AND to find products priced above 100 and in stock?
ASELECT * FROM products WHERE price > 100 AND stock > 0;
BSELECT * FROM products WHERE price > 100 OR stock > 0;
CSELECT * FROM products WHERE price > 100;
DSELECT * FROM products WHERE stock > 0;
If a row meets the first condition but not the second in a WHERE clause with AND, will it be included?
AYes, because one condition is true
BNo, because all conditions must be true
CYes, if the second condition is false
DNo, because <code>AND</code> ignores conditions
Can you use more than two conditions combined with AND in a WHERE clause?
AOnly three conditions are allowed
BNo, only two conditions are allowed
CYes, any number of conditions can be combined
DOnly if combined with <code>OR</code>
What is the result of this query? <br>SELECT * FROM users WHERE age > 18 AND city = 'Paris';
AUsers older than 18 who live in Paris
BUsers older than 18 or who live in Paris
CUsers younger than 18 who live in Paris
DAll users regardless of age or city
Explain how the WHERE clause with the AND operator filters data in SQL.
Think about how you pick fruits that are both ripe and red.
You got /4 concepts.
    Write an example SQL query using WHERE with AND to find records matching two conditions.
    Try to find employees who work in 'HR' and have a salary above 50000.
    You got /4 concepts.