Get startedGet started for free

Inner Join (III) - Join 3 tables

We've seen how to join 2 tables together - album with track, and album with artist. In this exercise, you'll join all three tables to pull together a more complete result set. You'll continue using INNER JOIN, but you need to specify more than one.

Here, note that because both track and artist contain a name column, you need to qualify where you are selecting the columns by prefixing the column name with the relevant table name.

This exercise is part of the course

Introduction to SQL Server

View Course

Exercise instructions

  • Qualify the name column by specifying the correct table prefix in both cases.
  • Complete both INNER JOIN clauses to join album with track, and artist with album.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT track_id,
-- Enter the correct table name prefix when retrieving the name column from the track table
  ___.name AS track_name,
  title as album_title,
  -- Enter the correct table name prefix when retrieving the name column from the artist table
  ___.name AS artist_name
FROM track
  -- Complete the matching columns to join album with track, and artist with album
INNER JOIN album on track.___ = album.album_id 
INNER JOIN artist on album.artist_id = artist.___;
Edit and Run Code