Challenge - 5 Problems
Comparison Operators Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of comparison with NULL using = operator
Consider the following SQL query:
What will be the result of this query?
SELECT * FROM employees WHERE manager_id = NULL;What will be the result of this query?
MySQL
SELECT * FROM employees WHERE manager_id = NULL;
Attempts:
2 left
💡 Hint
Remember how NULL behaves in comparisons in SQL.
✗ Incorrect
In SQL, comparing anything to NULL using = returns UNKNOWN, which is treated as false in WHERE clause, so no rows are returned.
❓ query_result
intermediate2:00remaining
Result of BETWEEN operator with boundary values
Given a table 'products' with a column 'price', what rows will this query return?
Specifically, will it include products priced exactly 10 or 20?
SELECT * FROM products WHERE price BETWEEN 10 AND 20;Specifically, will it include products priced exactly 10 or 20?
MySQL
SELECT * FROM products WHERE price BETWEEN 10 AND 20;
Attempts:
2 left
💡 Hint
BETWEEN includes the boundary values in SQL.
✗ Incorrect
The BETWEEN operator in SQL is inclusive, so it includes the boundary values 10 and 20.
📝 Syntax
advanced2:00remaining
Identify the invalid comparison operator usage
Which of the following SQL WHERE clauses will cause a syntax error?
Attempts:
2 left
💡 Hint
Check the correct syntax for 'not equal' in SQL.
✗ Incorrect
The operator '=!' is invalid in SQL. The correct 'not equal' operators are '<>' or '!='.
❓ optimization
advanced2:00remaining
Optimizing a query with multiple OR conditions
You have a table 'orders' with a column 'status'. Which query is more efficient to find orders with status 'pending', 'processing', or 'shipped'?
Attempts:
2 left
💡 Hint
Consider readability and how the database engine optimizes IN vs multiple ORs.
✗ Incorrect
Using IN is more concise and often optimized better by the database engine than multiple OR conditions.
🧠 Conceptual
expert2:00remaining
Understanding three-valued logic in SQL comparisons
In SQL, what is the result of the expression
5 = NULL and why?Attempts:
2 left
💡 Hint
Think about how SQL treats NULL in logical expressions.
✗ Incorrect
In SQL, any comparison with NULL results in UNKNOWN, which is treated as false in WHERE clauses but is distinct from TRUE or FALSE.