我的慈善机构的Access数据库有两个供志愿者使用的表:
Volunteers:
VID - ID of volunteer
ActiveGroups - Multivalue list of VolunteerGroups that they're active in
InterestGroupss - Multuvalue list of VolunteerGroups that they are interested in
VolunteerGroups:
ID - ID of group
GroupName - name of group我需要写一个查询,列出对一个组感兴趣的人,但不是那个组的一部分,并且完全卡住了。任何帮助都将不胜感激。谢谢
发布于 2017-04-18 20:27:22
多值字段很麻烦,应该避免,但据我所知,这应该可以工作(它两次加入VolunteerGroups表,一次在InterestGroups上内部检查person是否在该组中,一次在ActiveGroupss上,这样您就可以检查person不在该组中)
SELECT VID
FROM Volunteers
Inner Join VolunteerGroups As InterestedGroup ON InterestedGroup.ID = InterestedGroupss.Value
LEFT JOIN VolunteerGroups As ActiveGroup ON ActiveGroup.ID = ActiveGroups.Value
WHERE ActiveGroup.ID Is Nullhttps://stackoverflow.com/questions/43471272
复制相似问题