0
0
MySQLquery~20 mins

Selecting specific columns in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Selecting Specific Columns
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Selecting specific columns from a table
Given a table Employees with columns id, name, department, and salary, what is the output of this query?
SELECT name, salary FROM Employees WHERE department = 'Sales';
MySQL
SELECT name, salary FROM Employees WHERE department = 'Sales';
A[{"name": "Alice"}, {"name": "Bob"}]
B[{"id": 1, "name": "Alice", "salary": 50000}, {"id": 2, "name": "Bob", "salary": 55000}]
C[{"name": "Alice", "department": "Sales"}, {"name": "Bob", "department": "Sales"}]
D[{"name": "Alice", "salary": 50000}, {"name": "Bob", "salary": 55000}]
Attempts:
2 left
💡 Hint
The query selects only the name and salary columns for employees in the Sales department.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in column selection
Which option contains a syntax error when selecting specific columns from the Products table with columns product_id, product_name, and price?
ASELECT product_id, price FROM Products;
BSELECT product_name FROM Products;
CSELECT product_id product_name FROM Products;
DSELECT product_name, price FROM Products;
Attempts:
2 left
💡 Hint
Check if commas separate the column names.
query_result
advanced
2:00remaining
Selecting columns with aliasing
What is the output of this query on the Orders table with columns order_id, customer, and total?
SELECT order_id AS id, total AS amount FROM Orders WHERE total > 100;
MySQL
SELECT order_id AS id, total AS amount FROM Orders WHERE total > 100;
A[{"id": 101, "amount": 150}, {"id": 102, "amount": 200}]
B[{"order_id": 101, "total": 150}, {"order_id": 102, "total": 200}]
C[{"id": 101, "total": 150}, {"id": 102, "total": 200}]
D[{"order_id": 101, "amount": 150}, {"order_id": 102, "amount": 200}]
Attempts:
2 left
💡 Hint
The query renames columns using AS and filters totals greater than 100.
optimization
advanced
2:00remaining
Optimizing column selection for performance
You want to retrieve only the username and email columns from a large Users table. Which query is the most efficient?
ASELECT username, email FROM Users;
BSELECT username, email, password FROM Users;
CSELECT * FROM Users;
DSELECT email FROM Users;
Attempts:
2 left
💡 Hint
Selecting only needed columns reduces data transfer and processing.
🔧 Debug
expert
3:00remaining
Debugging incorrect column selection in join query
Given tables Customers(id, name) and Orders(id, customer_id, amount), which query correctly selects customer names and their order amounts?
ASELECT name, amount FROM Customers, Orders WHERE Customers.id = Orders.id;
BSELECT Customers.name, Orders.amount FROM Customers JOIN Orders ON Customers.id = Orders.customer_id;
CSELECT name, amount FROM Customers JOIN Orders ON Customers.id = Orders.id;
DSELECT Customers.name, Orders.amount FROM Customers JOIN Orders ON Customers.customer_id = Orders.id;
Attempts:
2 left
💡 Hint
Check the join condition matches customer id with order's customer_id.