Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can someone please help me understand this query in SQL?

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading