Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:50:13+00:00 2026-06-02T19:50:13+00:00

This seems as if it should be easy but I haven’t managed to create

  • 0

This seems as if it should be easy but I haven’t managed to create the proper query or to find an equivalent situation. Let’s say I have 3 tables that I’d like to join: Artist, Album, and Track. (Actually I don’t have these tables but the tables I’m working with have equivalent relationships.)

Each artist can have many albums and each album can have many tracks.

The artist table is indexed on artist_id and contains information about the artist (name, address, phone number, and such).

The album table is indexed on artist_id and album_id. It contains the name of the album and other information (recording date, location, etc).

The track table is indexed on artist_id, album_id, and track_nbr. It contains the name of the track, length, and such.

What I’m trying to do is create a report that would look like this:

Artist|Album|Track#|Track Name
The Wizard of Frobozz|Zork I|01|The White House
The Wizard of Frobozz|Zork I|02|Eaten by a Grue
The Wizard of Frobozz|Zork I|03|Take the Sword
The Wizard of Frobozz|Zork I|04|Don't Forget the Lantern
The Wizard of Frobozz|Zork II|01|Waiting for the Volcano Gnome
The Wizard of Frobozz|Zork II|02|On the Left Bank of Zork
The Wizard of Frobozz|Zork II|03|In the Oddly Angled Room

I can join the artist and album tables to get all of the albums but when I add the track table, I get only one track per album–artist combination.

This seems like it should work but doesn’t:

select a.name, l.album, t.track_nbr, t.track_name
from track t, album l, artist a 
where t.artist_id = l.artist_id
and l.artist_id = a.artist_id
and t.album_id = a.album_id
order by a.name, l.album, t.track_nbr;

My guess is that I need to explicitly declare a join and possibly add parentheses to group the joins but I haven’t been able to find documentation that I can fully comprehend to do this.

So … Help? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:50:14+00:00Added an answer on June 2, 2026 at 7:50 pm
     SELECT a.name, l.album, t.track_nbr, t.track_name
     FROM artist a
     LEFT JOIN album l ON a.artist_id = l.artist_id
     LEFT JOIN track t ON t.album_id = a.album_id
     ORDER BY a.name, l.album, t.track_nbr;
    

    Database design-related question: Why do you have artist_id in the track table? The artist_id is already defined through the album that this track belongs to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like it should be really easy but I couln't find an answer
It seems this should be easy but I'm having a lot of difficulty using
This seems like it should be an easy thing to do, but for the
This seems like it should be something very easy to do, but every time
This should be easy to find out but I can't seem to find it
So this should be a real easy question but I can't seem to find
This seems like it should be an easy fix, but after searching for hours
This seems like it should have a super easy solution, but I just can't
This seems like it should be prettty easy - but I just can't get
This seems like it should be a easy thing to do but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.