Exercises

Selected exercises in this section concern the music database. You’ll find that the description of table structures in The Music Database” in Chapter 4 is a useful reference:

  1. Write a join query that displays the name of each artist and the albums they’ve made. Alongside the album, display the number of tracks on the album.

  2. Repeat Question 1, but now display only those albums that have more than 10 tracks.

  3. Repeat Question 1, but write it as a nested query.

  4. What are the four types of nested queries? For each type, write a sample query on the music database. Try to use different keywords in each query, selecting from ANY, ALL, EXISTS (or NOT EXISTS), and IN (or NOT IN).

  5. What is the difference between an INNER JOIN, a LEFT JOIN, and a RIGHT JOIN? Does the order of tables matter in an INNER JOIN?

Get Learning MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.