SQL Joins and other clauses Assessment Question #3


My Code:

SELECT album.*, track.name AS tracks,artist.name AS artist_name
  FROM album 
  JOIN track 
    ON album.album_id=track.album_id
  JOIN artist 
    ON album.artist_id=artist.artist_id
 WHERE artist_name='Metallica';

What I expected to happen:

What actually happened:

I get the following  error
The set of joined table pairs is incorrect.

I don’t understand why the set of my joined tables is incorrect. I cann’t connect artist table directly with track. Or can I. I have tried but still I get the same error. I don’t know what I am doing wrong. Could someone explain. Thanks much.

Hey I was wondering if you had ever figured it out. I have similar if not the exact code you have and was wondering if you had gotten it fixed because I feel like I joined the correct tables to get at least track names related to Metallica, unless there are features that I am not aware of.

SELECT a.name artist_name, b.title album_name, t.name track_name
  FROM artist a
  JOIN album b
    ON b.artist_id = a.artist_id
  JOIN track t
    ON t.album_id = b.album_id
 WHERE a.name LIKE '%metallica%';

I never got an answer to this question or question 4 ,so I just left these two questions and moved on.

Here is the correct code:

SELECT t.name
  FROM track AS t
  JOIN album AS al
    ON t.album_id = al.album_id
  JOIN artist AS art
    ON al.artist_id = art.artist_id
 WHERE art.name LIKE '%Metallica%';

Thank you so much for your answer. I still don’t know why my code was wrong.