2017-04-18 137 views
0

我的慈善機構的Access數據庫有志願者2個表:該組的的MS 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 

我需要編寫一個查詢上市的人誰是有興趣在一組,而不是一部分,是完全被卡住。任何幫助將不勝感激。謝謝

+0

發佈架構。如果你在屬性中有多個值,那麼你不在1NF,你需要在繼續之前解決這個問題。 – nicomp

+0

@nicomp訪問多值字段實際上是獨立的表,用於處理不希望看到或使用額外表的人員的多對多關係。它們是1NF,因爲它們實際上是分開的表格(至少根據Microsoft,請參閱https://support.office.com/zh-cn/article/Guide-to-multivalued-fields-7c2fd644-3771-48e4-b6dc-6de9bebbec31 ) –

+0

@ErikvonAsmuth我明白你的意思了。那些超級笨拙的,我不使用它們:我只是創建外鍵,並在必要時填充控件。 – nicomp

回答

0

多值字段是一個麻煩,應該避免,但據我所知,這應該工作(它將加入VolunteerGroups表兩次, ActiveGroupss,以便您可以查看該人不在該組中)

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 Null