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.
Which SQL operator is used to combine the results of multiple SELECT queries?
2.
How can you combine two result sets that have the same structure but remove duplicate rows?
3.
Which join includes all records from the right table and only matching records from the left table?
4.
What is the purpose of the ON clause in a JOIN statement?
5.
What does the USING clause do in a JOIN?
6.
What is the primary purpose of using joins in MySQL?
7.
What happens if you perform a RIGHT JOIN and there are no matching records in the left table?
8.
How can you retrieve only matching records from two tables, ensuring no duplicate records appear in the final result set?
9.
Which type of join returns only matching rows from both tables?
10.
What is the difference between UNION and UNION ALL?
11.
What does a CROSS JOIN do?
12.
Which statement correctly performs an INNER JOIN between two tables named 'customers' and 'orders'?
13.
Which SQL keyword is used to perform a full outer join in MySQL?
14.
What will a LEFT JOIN return if there are no matching records in the right table?
15.
Which type of join can result in a Cartesian product?
16.
Which MySQL function is useful in joins to handle NULL values?