MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:EXISTS, ANY and ALL Clause
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, the EXISTS clause is used to check if any rows are returned by a subquery.

Q2
True / False

The ANY clause in MySQL is used to compare a value to a single value returned by a subquery.

Q3
True / False

In MySQL, the ALL clause can be used with the SELECT statement to fetch all columns from a table.

Q4
True / False

MySQL's EXISTS clause can be used to improve query performance by stopping the search once a match is found.

Q5
True / False

The ANY clause in MySQL can be used with comparison operators like =, <, and >.

Q6
True / False

Using the ALL clause with a comparison operator in MySQL ensures that the comparison is true for every value returned by the subquery.

Q7
True / False

In MySQL, EXISTS can be used within a JOIN condition to filter results.

Q8
True / False

The ANY clause in MySQL can be used with the IN operator to match any of the values returned by a subquery.

Q9
True / False

The ALL clause in MySQL can be used with aggregate functions like COUNT, SUM, and AVG.

Q10
True / False

In MySQL, using the EXISTS clause with a subquery that includes GROUP BY will always return the same result as using the ANY clause with the same subquery.

Q11
Single Choice

Which MySQL clause would you use to check if a subquery returns any rows?

Q12
Single Choice

What does this query do?

SQL Code
Consider the following SQL query:
SELECT * FROM Employees e
WHERE NOT EXISTS (SELECT 1 FROM Departments d WHERE d.department_id = e.department_id);
Q13
Single Choice

Which of the following MySQL clauses can be used to determine if a value is greater than all the values returned by a subquery?

Q14
Single Choice

Given the following query:

SQL Code
SELECT * FROM Orders o
WHERE o.amount > ALL (SELECT amount FROM Discounts WHERE discount_type = 'Seasonal');
What does this query return?
Q15
Single Choice

Which of the following statements is true regarding the MySQL NOT EXISTS clause?

Q16
Single Choice

What does the following query return?

SQL Code
SELECT * FROM Products p
WHERE p.price = ANY (SELECT price FROM Products WHERE category = 'Electronics');
Q17
Single Choice

What does this query return?

SQL Code
Analyze the following query:
SELECT * FROM Sales s
WHERE s.total < ALL (SELECT total FROM Sales WHERE region = 'North');
Q18
Single Choice

What does the following query achieve?

SQL Code
DELETE FROM Orders o
WHERE NOT EXISTS (SELECT 1 FROM Customers c WHERE c.customer_id = o.customer_id);
Q19
Single Choice

What is the query returning?

SQL Code
Consider the query:
SELECT * FROM Employees e
WHERE e.salary > ANY (SELECT salary FROM Employees WHERE department_id = 10);
Q20
Single Choice

Which of the following queries returns all products that have a price lower than every product in the 'Furniture' category?

Q21
Multiple Choice

Which query correctly retrieves records from the 'employees' table where there exists at least one related record in the 'departments' table?

SQL Code
SELECT *
FROM employees e
WHERE EXISTS (
 SELECT 1
 FROM departments d
 WHERE d.department_id = e.department_id
);
Q22
Multiple Choice

Identify the correct SQL query that retrieves records from the 'orders' table where the 'order_amount' is greater than any order amount in the 'invoices' table.

SQL Code
SELECT *
FROM orders o
WHERE o.order_amount > ANY (
 SELECT i.invoice_amount
 FROM invoices i
);
Q23
Multiple Choice

Which query correctly selects records from the 'products' table where the 'price' is less than the price of all products in the 'competitors' table?

SQL Code
SELECT *
FROM products p
WHERE p.price < ALL (
 SELECT c.price
 FROM competitors c
);
Q24
Multiple Choice

Determine the correct SQL query that retrieves records from the 'customers' table where there is no matching record in the 'orders' table.

SQL Code
SELECT *
FROM customers c
WHERE NOT EXISTS (
 SELECT 1
 FROM orders o
 WHERE o.customer_id = c.customer_id
);
Q25
Multiple Choice

Which SQL query retrieves records from the 'inventory' table where the 'quantity' is equal to any quantity in the 'sales' table?

SQL Code
SELECT *
FROM inventory i
WHERE i.quantity = ANY (
 SELECT s.quantity
 FROM sales s
);
Q26
Multiple Choice

Which query correctly retrieves records from the 'employees' table where the 'salary' is greater than all salaries in the 'managers' table?

SQL Code
SELECT *
FROM employees e
WHERE e.salary > ALL (
 SELECT m.salary
 FROM managers m
);
Q27
Multiple Choice

Determine the correct SQL query that selects records from the 'transactions' table where the 'transaction_amount' is equal to all transaction amounts in the 'refunds' table.

SQL Code
SELECT *
FROM transactions t
WHERE t.transaction_amount = ALL (
 SELECT r.amount
 FROM refunds r
);
Q28
Multiple Choice

Which SQL query retrieves records from the 'projects' table where the 'budget' is not equal to any budget in the 'competitors_projects' table?

SQL Code
SELECT *
FROM projects p
WHERE p.budget <> ALL (
 SELECT cp.budget
 FROM competitors_projects cp
);
Q29
Multiple Choice

Identify the correct query that retrieves records from the 'clients' table where the 'client_id' exists in the 'high_value_clients' table.

SQL Code
SELECT *
FROM clients c
WHERE EXISTS (
 SELECT 1
 FROM high_value_clients hvc
 WHERE hvc.client_id = c.client_id
);
Q30
Multiple Choice

Which SQL query correctly retrieves records from the 'students' table where the 'grade' is greater than or equal to all grades in the 'exams' table?

SQL Code
SELECT *
FROM students s
WHERE s.grade >= ALL (
 SELECT e.grade
 FROM exams e
);