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:
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.
Repeat Question 1, but now display only those albums that have more than 10 tracks.
Repeat Question 1, but write it as a nested query.
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 fromANY
,ALL
,EXISTS
(orNOT EXISTS
), andIN
(orNOT IN
).What is the difference between an
INNER JOIN
, aLEFT JOIN
, and aRIGHT JOIN
? Does the order of tables matter in anINNER 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.