Query Help - Joining 5 tables
Posted: Sun Aug 28, 2011 5:54 pm
Ok, I have got myself into a complicated situation where I have 5 tables and need to join them all in one mySQL query. Here is a basic outline of my table structure for this example.
Songs
ID | Song_Name
Genres
ID | Genre_Name
Groups
ID | Group_Name
Song_Genres (links songs table to genres table)
Song_ID | Genre_ID
Group_Linking (links groups table to genres table)
Genre_ID | Group_ID
I have genre "groups" where you might combine country and western into a similar group to pull together. Each song can be listed in multiple genres, and each genre can be in multiple groups. That's why i need the 2 linking tables.
Now what I am trying to do is pull all songs that are in group 1. It sounds really easy, but I am not able to wrap my head around it yet. I would appreciate any help! Am I overcomplicating this?
Thanks!
Songs
ID | Song_Name
Genres
ID | Genre_Name
Groups
ID | Group_Name
Song_Genres (links songs table to genres table)
Song_ID | Genre_ID
Group_Linking (links groups table to genres table)
Genre_ID | Group_ID
I have genre "groups" where you might combine country and western into a similar group to pull together. Each song can be listed in multiple genres, and each genre can be in multiple groups. That's why i need the 2 linking tables.
Now what I am trying to do is pull all songs that are in group 1. It sounds really easy, but I am not able to wrap my head around it yet. I would appreciate any help! Am I overcomplicating this?
Thanks!