Given we have a database with the tables:
“artist” (columns: name, id) and
“song” (title, composers_id, songwriters_id).
I want to print the songs with the composers name and songwriters name.
I have succeeded in printing the composers name only with:
SELECT title, name AS Composers_Name
FROM artist, song
WHERE song.composers_id = artist.id;
I am failing to fetch the songwriters name..
What I tried was this:
SELECT title, name AS Composers_Name, name AS Songwriters_name
FROM artist, song
WHERE song.composers_id = artist.id AND song.songwriters_id = artist.id;
But this returns all the songs that the composers and songwriter is the same person.
I am thinking of using JOIN but I’m not sure how..
You have to select from the table artist 2 times.
assuming that Composers and Songwriters are both stored in the table artist.