php - SQL get information from one table based on another's row value and vice versa -
i indexing music download in mysql database , limited 2 databases total. have decided organize database this:
database:
music > artist >> artists >> artistr >> genre > album >> album >> artists >> year > song >> song >> album >> artists
i want know if there way enter 1 of these values, , of results of tables (e.g. enter "blues", artists table artist "blues" genre, albums artist because artist has genre "blues", , of songs albums artists because have genre "blues").
please if need information or clarification.
make artists primary key in artist table , make foreign key in album table , associate artists column in album table. same album column of album table make primary key , make foreign key in song table associated album column. insert data in tables make sure enter values in foreign key column same primary key associated e.g in
artist table
artists = abc (primary key) artsitr = xyz genre = blues
in album table
album = pqr (primary key) artists = abc (foreign key)same value in table artist year = 1990
in song table
song = mno album = pqr (foreign key)same value in table album artists = klm
now use query
select artist.artists,artist.genre, artist.artistr, artist.album,album.artists,album.year, song.song,song.artists artist inner join album on album.artists = artist.artists inner join song on song.album = album.album artist.genre = 'blues'
hope you..
Comments
Post a Comment