php - SQL inner join of multiple tables and search through database -
i'm making search function in php , have 3 tables wish join single one; 3 tables looks follow:
band id | bands ---+---------- 1 | muse 2 | coldplay 3 | etc. release id | releases ---+---------- 1 | showbiz 2 | origin of symmentry 3 | etc. track id | tracks ---+----------- 1 | sunburn 2 | muscle museum 3 | etc.
i want these tables put this:
discografic id | band_id | release_id | track_id ---+----------+-------------+--------- 1 | 1 | 1 | 1 2 | 1 | 1 | 2 3 | etc.
so table sql code looks this:
discografic id | bands | releases | tracks ---+----------+-------------+--------- 1 | muse | showbiz | sunburn 2 | muse | showbiz | muscle museum 3 | etc.
i want inner join
these tables. joined 1 can't figure out how last joined well.
select * band inner join discografic on band.id = discografic.band_id
this should have own question; want able search database, have result show once, , reference band every time. example, if search "showbiz"
give me "muse"
, , show once.
note: testing purposes only, security none of concerns.
try query
select a.id,b.bands,c.releases,d.tracks discografic inner join band b on a.band_id = b.id inner join release c on a.release_id = c.id inner join track d on a.track_id = d.id b.bands = 'muse'
Comments
Post a Comment