JOIN questions & many-to-many db relationship

Hey all,

Ive been working with php for a little while now and have just discovered the world of database normilization. whilst i totally understand how to structure my database conforming to 3NF im having trouble getting my head around the query i should be using to handle a many to many db relationship.

i have the following tables

gigs

gig_id
venue_id


venues

venue_id


gig_list

gig_list_id
gig_id
band_id


bands

band_id

i wrote a query originally like this
SELECT * FROM gigs,venues,gig_list,bands WHERE gigs.gig_id = 1 AND venues.venue_id = gigs.venue_id AND gig_list.gig_id = 1 AND bands.band_id = gig_list.band_id

which produced results but obv not right. i thought maybe i should be doing this in two quries but i just cant get my head around it. Any help is greatly appreciated

Sponsor our Newsletter | Privacy Policy | Terms of Service