vitid Posted February 28, 2009 Share Posted February 28, 2009 let say that i have 3 tables as follow member id name 1 a 2 b 3 c group id name 1 group1 2 group2 groupmembermap group_idmember_id 11 12 21 23 how to create statement to return group's name that has both member name a and b please help me , i try googling for an hour with no success , i try subquery it but guess i'm hopeless , thank you. Quote Link to comment https://forums.phpfreaks.com/topic/147297-help-sql-noober-please/ Share on other sites More sharing options...
fenway Posted February 28, 2009 Share Posted February 28, 2009 how about this? select g.name from group as g cross join member as m1 cross join member as m2 inner join groupmembermap as gm1 on ( gm1.group_id = g.id and gm1.member_id = m1.id ) inner join groupmembermap as gm2 on ( gm1.group_id = g.id and gm1.member_id = m1.id ) where m1.name = 'a' and m2.name = 'b' Quote Link to comment https://forums.phpfreaks.com/topic/147297-help-sql-noober-please/#findComment-773327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.