0
0
MySQLquery~20 mins

WHERE clause filtering in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
WHERE Clause Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Filter employees with salary greater than 50000
Given a table employees with columns id, name, and salary, which query returns all employees earning more than 50000?
MySQL
SELECT * FROM employees WHERE salary > 50000;
ASELECT * FROM employees WHERE salary < 50000;
BSELECT * FROM employees WHERE salary >= 50000;
CSELECT * FROM employees WHERE salary > 50000;
DSELECT * FROM employees WHERE salary = 50000;
Attempts:
2 left
💡 Hint
Think about the meaning of the > operator in filtering salaries.
query_result
intermediate
2:00remaining
Find customers from specific cities
Given a table customers with columns id, name, and city, which query returns customers from either 'New York' or 'Los Angeles'?
MySQL
SELECT * FROM customers WHERE city = 'New York' OR city = 'Los Angeles';
ASELECT * FROM customers WHERE city = 'New York' OR city = 'Los Angeles';
BSELECT * FROM customers WHERE city IN ('New York', 'Los Angeles');
CSELECT * FROM customers WHERE city = 'New York' AND city = 'Los Angeles';
DSELECT * FROM customers WHERE city LIKE 'New York' OR city LIKE 'Los Angeles';
Attempts:
2 left
💡 Hint
Use OR to include multiple possible values.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this WHERE clause
Which option contains a syntax error in the WHERE clause?
MySQL
SELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31';
ASELECT * FROM orders WHERE order_date > '2023-01-01' AND order_date < '2023-12-31';
BSELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31';
CSELECT * FROM orders WHERE order_date >= '2023-01-01' AND order_date <= '2023-12-31';
DSELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' TO '2023-12-31';
Attempts:
2 left
💡 Hint
Check the correct syntax for BETWEEN operator.
optimization
advanced
2:00remaining
Optimize filtering for multiple values
Which query is the most efficient way to filter rows where status is 'active', 'pending', or 'suspended'?
ASELECT * FROM users WHERE status = 'active' OR status = 'pending' OR status = 'suspended';
BSELECT * FROM users WHERE status IN ('active', 'pending', 'suspended');
CSELECT * FROM users WHERE status LIKE 'active' OR status LIKE 'pending' OR status LIKE 'suspended';
DSELECT * FROM users WHERE status = 'active' AND status = 'pending' AND status = 'suspended';
Attempts:
2 left
💡 Hint
Use a concise operator for multiple values.
🧠 Conceptual
expert
2:00remaining
Understanding NULL filtering in WHERE clause
Given a table products with a column discount that can be NULL, which query correctly selects products with no discount?
ASELECT * FROM products WHERE discount IS NULL;
BSELECT * FROM products WHERE discount = NULL;
CSELECT * FROM products WHERE discount = 0;
DSELECT * FROM products WHERE discount != NULL;
Attempts:
2 left
💡 Hint
Remember how SQL treats NULL comparisons.