-5
Suppose these are the tables:
Table of Members
CREATE TABLE Integrantes(
ID INT AUTO_INCREMENT PRIMARY KEY,
Nome NVARCHAR(50) NOT NULL,
);
Band 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
);
Table of Record Companies
CREATE TABLE Gravadoras(
ID INT AUTO_INCREMENT PRIMARY KEY,
Gravadora NVARCHAR(50) NOT NULL,
);
Table of Songs
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’ve helped!
What you want to return?
– Roberto de Campos
Possible duplicate of How to relate several tables?
– Homer Simpson
yes! I want a select
– AKU
You could explain better what you want? On that other question of yours you explained a little better by saying that you wanted to exchange the foreign key values of
inf_musicas
by the values of the other tables. Is that what you want to do here? If so, what is the specific difficulty that is not elucidated in your other question? If not, then what is it you need?– Victor Stafusa