The tables are from the Chinook database.(https://i.stack.imgur.com/t0jcm.png)
Q) Retrieve the track name, album, artist, and trackID for all the albums
SELECT Tracks.Name,
A.Name AS Artist ,
Albums.Title AS Album ,
Tracks.TrackId
FROM ((Tracks INNER JOIN Albums
ON Tracks.AlbumId = Albums.AlbumId)
INNER JOIN Artists A
ON A.ArtistId = Albums.ArtistId);
What I tried:
SELECT Tracks.Name,
Aritst.Name AS Artist,
Albums.Title AS Album,
Tracks.TrackId
FROM ((Tracks INNER JOIN Albums
ON Tracks.AlbumId = Albums.AlbumId)
INNER JOIN Artists A
ON Artist.ArtistId = Albums.ArtistId);
>Solution :
The first query is basically trying to join the Tracks table with Albums table to get the album details, and also tracks table with artists table to get the artist details.
Once you’ve joined all three tables, you are able to get the data track name, album, artist, and trackID from the records.