I have the following many-to-many relationship, linking "Contact" and "Distribution_List__c" with the "Distribution_List_Junction__c" object:
Contact - Distribution_List_Junction__c - Distribution_List__c
Given a particular Distribution List name, I am trying to retrieve the email addresses of its member Contacts. So far I have the following, which seems to retrieve Contact IDs as child records:
SELECT (select Contact__c from Distribution_List_Junctions__r ) FROM Distribution_List__c WHERE Name = 'Distribution List 1'
However, I'm not sure where to go from here. I assume that I will have to then query the Contacts object based on those Contact IDs, but I can't tell how to do that efficiently. Is it even necessary to do the separate query?
I'd really appreciate your help.