Skip to content
Advertisement

How to find every genre from an artist in a music database in MYSQL?

So I’ve got a database with 4 tables: artist, genre, track and album. Track table points in a many to one way to Genre table, and so on with Track to Album, and Album to Artist.

Suppose I want to find every genre that ‘John Coltrane’ plays, so I thought about saying

But this just gives me

enter image description here

i.e. ALL genres jointed to John Coltrane, instead of just ‘Jazz’ which is what I’m seeking…

Why is it not working?

Advertisement

Answer

Since you didn’t show all the table columns which would be used to join tables together. I will make some assumptions for you. I will be more accurate if I notice that you updated the topic and I will update my answer when I see it. Where I am incorrect about the column name that I join on just substitute the actual column with the one I put here and it will do what you are trying to do. 😉

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement