how do I join inner join with these tables?

-5

How would the SELECT query in Mysql of the Inf_musics table be?

    
asked by anonymous 16.02.2018 / 03:17

1 answer

2

Assuming these are the table:

Membership Table

CREATE TABLE Integrantes(
   ID INT AUTO_INCREMENT PRIMARY KEY,
   Nome NVARCHAR(50) NOT NULL,
);

Banding Table

CREATE TABLE Bandas(
   ID INT AUTO_INCREMENT PRIMARY KEY,
   Banda NVARCHAR(50) NOT NULL,
   IntegranteID INT NOT NULL,

   CONSTRAINT FK_IntegrantesDaBanda
   FOREIGN KEY (IntegranteID)
   REFERENCES Integrantes.ID
);

Recorders Table

CREATE TABLE Gravadoras(
   ID INT AUTO_INCREMENT PRIMARY KEY,
   Gravadora NVARCHAR(50) NOT NULL,
);

Song Chart

CREATE TABLE Musicas(
   ID INT AUTO_INCREMENT PRIMARY KEY,
   Musica NVARCHAR(50) NOT NULL,
   BandaID INT NOT NULL,
   GravadoraID INT NOT NULL,

   CONSTRAINT FK_MusicaDaBanda
   FOREIGN KEY (BandaID)
   REFERENCES Bandas.ID,

  CONSTRAINT FK_MusicaDaGravadora
   FOREIGN KEY (GravadoraID)
   REFERENCES Gravadoras.ID
);

Query

SELECT M.Musica, B.Banda, G.Gravadora FROM Musicas AS M
INNER JOIN Bandas AS B ON M.BandaID = B.ID
INNER JOIN Gravadoras AS G ON M.GravadoraID = G.ID

I hope I have helped!

    
16.02.2018 / 05:02