join - MySQL: how to combine three tables -
i have table persons (personid,name), table camps (campid,title) , third table camp participations (id,personid,campid).
now, given camp, need list of other camp participations persons participating in current camp.
but have no idea how join these tables. have looked @ lot of other examples, can't seem inspiration those...
this should work:
select * persons d inner join camp_participations e on d.personid = e.personid inner join camps f on f.campid = e.campid f.campid <> [your_camp] , a.personid in ( select a.personid persons inner join camp_participations b on a.personid = b.personid inner join camps c on c.campid = b.campid c.campid = [your_camp] )
Comments
Post a Comment