Joins allow us to combine data from multiple tables based on a common column, helping retrieve meaningful results efficiently. MySQL supports INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN, and FULL OUTER JOIN(simulated using UNION).
The UNION and UNION ALL operators merge result sets from multiple queries, with UNION removing duplicates and UNION ALL keeping them.
This quiz will test your understanding of MySQL joins and unions.
1.
How can you retrieve only matching records from two tables, ensuring no duplicate records appear in the final result set?
2.
What is the purpose of the ON clause in a JOIN statement?
3.
What does a CROSS JOIN do?
4.
Which type of join can result in a Cartesian product?
5.
Which type of join returns only matching rows from both tables?
6.
What is the difference between UNION and UNION ALL?
7.
Which SQL keyword is used to perform a full outer join in MySQL?
8.
Which statement correctly performs an INNER JOIN between two tables named 'customers' and 'orders'?
10.
Which SQL operator is used to combine the results of multiple SELECT queries?
11.
What happens if you perform a RIGHT JOIN and there are no matching records in the left table?
12.
What is the primary purpose of using joins in MySQL?
13.
How can you combine two result sets that have the same structure but remove duplicate rows?
14.
Which join includes all records from the right table and only matching records from the left table?
15.
Which MySQL function is useful in joins to handle NULL values?
16.
What does the USING clause do in a JOIN?
17.
What will a LEFT JOIN return if there are no matching records in the right table?