0
0
SQLquery~5 mins

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

Choose your learning style9 modes available
Recall & Review
beginner
What does the OR operator do in a SQL WHERE clause?
The OR operator allows you to filter rows that meet at least one of multiple conditions. If any condition separated by OR is true, the row is included in the result.
Click to reveal answer
beginner
Write a simple SQL query using WHERE with OR to find employees in department 10 or department 20.
SELECT * FROM employees WHERE department_id = 10 OR department_id = 20;
Click to reveal answer
beginner
Can you combine multiple OR conditions in a WHERE clause?
Yes, you can combine many OR conditions. For example: WHERE condition1 OR condition2 OR condition3. The row is included if any condition is true.
Click to reveal answer
intermediate
How does SQL evaluate WHERE conditions with OR and AND together?
SQL evaluates AND before OR unless parentheses change the order. Use parentheses to group conditions clearly, e.g., WHERE (A OR B) AND C.
Click to reveal answer
beginner
What happens if you use OR with conditions that never match any row?
If none of the OR conditions are true for a row, that row is excluded from the result. OR only includes rows where at least one condition is true.
Click to reveal answer
Which SQL query finds rows where column A is 5 or column B is 10?
ASELECT * FROM table WHERE B = 10;
BSELECT * FROM table WHERE A = 5 AND B = 10;
CSELECT * FROM table WHERE A = 5;
DSELECT * FROM table WHERE A = 5 OR B = 10;
What does this query return? SELECT * FROM users WHERE age = 20 OR age = 30;
AUsers who are exactly 20 or exactly 30 years old.
BUsers who are between 20 and 30 years old.
CUsers who are not 20 or 30 years old.
DUsers who are both 20 and 30 years old.
How does SQL treat this condition? WHERE A = 1 OR B = 2 AND C = 3
AIt treats AND before OR, so it's A=1 OR (B=2 AND C=3).
BIt treats OR before AND, so it's (A=1 OR B=2) AND C=3.
CIt treats all conditions equally and randomly.
DIt causes a syntax error.
Which is true about the OR operator in SQL WHERE clause?
AIt returns rows where all conditions are true.
BIt returns rows where at least one condition is true.
CIt returns rows where no conditions are true.
DIt returns rows only if conditions are false.
What is the result of this query? SELECT * FROM products WHERE price < 10 OR price > 100;
AProducts priced exactly 10 or 100.
BProducts priced between 10 and 100.
CProducts priced less than 10 or greater than 100.
DNo products will be returned.
Explain how the OR operator works in a SQL WHERE clause and give a simple example.
Think about choosing between two or more options.
You got /3 concepts.
    Describe how SQL evaluates WHERE conditions when both AND and OR operators are used together.
    Remember the order of operations like in math.
    You got /3 concepts.