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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -