MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:SQL Execution Order
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, the SELECT clause is executed before the WHERE clause.

Q2
True / False

In MySQL, the FROM clause is always executed first.

Q3
True / False

The ORDER BY clause in MySQL is executed before the GROUP BY clause.

Q4
True / False

In MySQL, the HAVING clause can filter records before the GROUP BY clause.

Q5
True / False

In MySQL, the LIMIT clause is always executed last.

Q6
True / False

In MySQL, the JOIN operations are performed before the WHERE clause is evaluated.

Q7
True / False

In MySQL, subqueries in the SELECT clause are executed before the WHERE clause.

Q8
True / False

In MySQL, the DISTINCT keyword is applied before the ORDER BY clause.

Q9
True / False

In MySQL, window functions are evaluated after the WHERE and GROUP BY clauses but before the ORDER BY clause.

Q10
True / False

In MySQL, the WITH clause (Common Table Expressions) is executed before the main query.

Q11
Single Choice

Which of the following statements is executed first in a MySQL query?

Q12
Single Choice

What will be the result of the following MySQL query?

SQL Code
SELECT COUNT(*)
FROM employees;
Q13
Single Choice

In MySQL, what does the following SQL command do?

SQL Code
DELETE FROM products WHERE product_id = 10;
Q14
Single Choice

Which statement is true about this query execution?

SQL Code
Consider the following query:
SELECT department, SUM(salary)
FROM employees
GROUP BY department
HAVING SUM(salary) > 100000;
Q15
Single Choice

What will the following MySQL query return?

SQL Code
SELECT employee_name, salary * 1.10 AS adjusted_salary
FROM employees
WHERE salary > 50000;
Q16
Single Choice

Which MySQL clause is responsible for limiting the number of records returned by a query?

Q17
Single Choice

What does the following MySQL query achieve?

SQL Code
SELECT employee_id,
 (SELECT department_name FROM departments WHERE departments.department_id = employees.department_id) AS department
FROM employees;
Q18
Single Choice

In MySQL, which of the following describes how subqueries are executed?

Q19
Single Choice

What is the purpose of the following MySQL query?

SQL Code
UPDATE employees
SET salary = salary * 1.05
WHERE employee_id IN (SELECT employee_id FROM bonuses WHERE bonus > 5000);
Q20
Single Choice

What can be inferred from the execution plan output if the type column shows index?

SQL Code
Consider the following MySQL query execution plan:
EXPLAIN SELECT * FROM orders WHERE order_date > '2024-01-01' ORDER BY customer_id LIMIT 10;
Q21
Multiple Choice

Which SQL query correctly demonstrates the execution order from WHERE to GROUP BY?

SQL Code
SELECT department, COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY department;
Q22
Multiple Choice

Identify the SQL query that correctly demonstrates the execution order including JOIN operations.

SQL Code
SELECT e.name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id
WHERE e.salary > 50000;
Q23
Multiple Choice

Which SQL query demonstrates the execution order involving a subquery in the WHERE clause?

SQL Code
SELECT name
FROM employees
WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'Sales');
Q24
Multiple Choice

Determine the SQL query that correctly uses the execution order with HAVING after GROUP BY.

SQL Code
SELECT department, COUNT(*)
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
Q25
Multiple Choice

Which SQL query correctly demonstrates the use of ORDER BY after SELECT?

SQL Code
SELECT name, salary
FROM employees
WHERE department_id = 3
ORDER BY salary DESC;
Q26
Multiple Choice

Which SQL query illustrates the correct execution order when combining DISTINCT and GROUP BY?

SQL Code
SELECT DISTINCT department_id
FROM employees
GROUP BY department_id;
Q27
Multiple Choice

Identify the SQL query that correctly orders the operations for LIMIT after ORDER BY.

SQL Code
SELECT name, salary
FROM employees
ORDER BY salary DESC
LIMIT 10;
Q28
Multiple Choice

Which SQL query demonstrates the correct execution order for a query that uses both JOIN and WHERE?

SQL Code
SELECT e.name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id
WHERE d.department_name = 'Sales';
Q29
Multiple Choice

Determine the SQL query that follows the correct execution order when using a subquery in the SELECT clause.

SQL Code
SELECT name, (SELECT department_name FROM departments WHERE department_id = e.department_id) AS dept_name
FROM employees e;
Q30
Multiple Choice

Which SQL query demonstrates the correct execution order for complex queries with multiple clauses, including WHERE, GROUP BY, HAVING, and ORDER BY?

SQL Code
SELECT department, COUNT(*) AS num_employees
FROM employees
WHERE salary > 50000
GROUP BY department
HAVING num_employees > 10
ORDER BY num_employees DESC;