MySQL Database Quiz Questions

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

In MySQL, the UNION operator combines the results of two or more SELECT statements and removes duplicate rows.

Q2
True / False

UNION ALL in MySQL includes duplicates in the result set.

Q3
True / False

The number of columns in each SELECT statement used with UNION must be different.

Q4
True / False

The ORDER BY clause can be used with UNION or UNION ALL to sort the final result set.

Q5
True / False

MySQL requires that all SELECT statements in a UNION query have the same column names.

Q6
True / False

Using UNION ALL is generally faster than using UNION because UNION ALL does not perform a duplicate check.

Q7
True / False

You can use UNION or UNION ALL with subqueries in MySQL.

Q8
True / False

The UNION operator can only be used with SELECT statements that have columns of exactly the same data types in MySQL.

Q9
True / False

You can use LIMIT in conjunction with UNION ALL to limit the number of rows returned in MySQL.

Q10
True / False

When using UNION in MySQL, the columns selected must be in the same order for each SELECT statement involved.

Q11
Single Choice

Which MySQL keyword is used to combine the result set of two or more SELECT statements and automatically remove duplicates?

Q12
Single Choice

Given the following SQL query, which of the following is correct about the result set?

SQL Code
SELECT city FROM customers
UNION
SELECT city FROM suppliers;
Q13
Single Choice

What is the key difference between UNION and UNION ALL in MySQL?

Q14
Single Choice

Given two tables employees and managers, how would you write a query to list all unique employee and manager names using MySQL?

Q15
Single Choice

If you want to combine the results of two queries and ensure that all duplicates are included in the final result, which MySQL keyword should you use?

Q16
Single Choice

Which statement is true about their results?

SQL Code
Consider the following two SQL queries
SELECT product_id FROM products_a
UNION
SELECT product_id FROM products_b;
SELECT product_id FROM products_a
UNION ALL
SELECT product_id FROM products_b;
Q17
Single Choice

Which of the following queries will return all rows from both the sales and purchases tables, including duplicates, while sorting the result set by transaction_date in descending order?

Q18
Single Choice

You have two queries that select the same columns from different tables but with different conditions. You want to combine the results and remove duplicates, then sort by one of the columns. Which MySQL keyword would you use and where would you place the ORDER BY clause?

Q19
Single Choice

Consider two tables orders_2023 and orders_2024, each having columns order_id and order_date. Write a query using UNION ALL that lists all orders from both tables without removing duplicates and sorts the results by order_date in ascending order. Which query would you use?

Q20
Single Choice

Given two complex queries that retrieve data from several joined tables, you want to combine their results, remove duplicates, and then sort by a calculated column (e.g., total_sales). How would you structure your query in MySQL?

Q21
Multiple Choice

Which SQL query uses UNION to combine the results from the 'employees' and 'managers' tables, returning unique records?

SQL Code
SELECT employee_id, name FROM employees
UNION
SELECT manager_id, name FROM managers;
Q22
Multiple Choice

Identify the correct SQL query that uses UNION ALL to combine the results from the 'orders' and 'shipments' tables, including all duplicate records.

SQL Code
SELECT order_id, order_date FROM orders
UNION ALL
SELECT shipment_id, shipment_date FROM shipments;
Q23
Multiple Choice

Which SQL query uses UNION to retrieve all customer names from the 'domestic_customers' and 'international_customers' tables without duplicates?

SQL Code
SELECT customer_name FROM domestic_customers
UNION
SELECT customer_name FROM international_customers;
Q24
Multiple Choice

Determine the correct SQL query that uses UNION ALL to combine the 'products' and 'services' tables, showing all product and service names, including duplicates.

SQL Code
SELECT product_name FROM products
UNION ALL
SELECT service_name FROM services;
Q25
Multiple Choice

Which SQL query uses UNION to combine the results from the 'current_employees' and 'former_employees' tables, ensuring no duplicates are returned?

SQL Code
SELECT employee_id, name FROM current_employees
UNION
SELECT employee_id, name FROM former_employees;
Q26
Multiple Choice

Which SQL query uses UNION ALL to combine the results from the 'vendors' and 'suppliers' tables, showing all vendor and supplier names, including duplicates?

SQL Code
SELECT vendor_name FROM vendors
UNION ALL
SELECT supplier_name FROM suppliers;
Q27
Multiple Choice

Identify the correct SQL query that uses UNION to retrieve all distinct product names from the 'electronics' and 'furniture' tables.

SQL Code
SELECT product_name FROM electronics
UNION
SELECT product_name FROM furniture;
Q28
Multiple Choice

Which SQL query uses UNION ALL to combine the results from the 'north_america_sales' and 'europe_sales' tables, showing all sales records including duplicates?

SQL Code
SELECT sale_id, amount FROM north_america_sales
UNION ALL
SELECT sale_id, amount FROM europe_sales;
Q29
Multiple Choice

Determine the correct SQL query that uses UNION to retrieve all unique student names from the 'undergraduates' and 'postgraduates' tables.

SQL Code
SELECT student_name FROM undergraduates
UNION
SELECT student_name FROM postgraduates;
Q30
Multiple Choice

Which SQL query uses UNION ALL to combine the results from the 'domestic_sales' and 'international_sales' tables, showing all sales records including duplicates?

SQL Code
SELECT sale_id, total_amount FROM domestic_sales
UNION ALL
SELECT sale_id, total_amount FROM international_sales;