You need to sign in to do that
Don't have an account?

Comparing values from list using value from another list in apex
Hi,
I'm trying to return values from a list in an apex class using the value from another list.
So I have list1 = [Select Contact__r.ContactEmail from Registrations__c Id in : lstRegistrations]
and what I want to do is check all the records from another object using the value of ContactEmail from above list.
So something like this:
list2=[Select Email from Site__c where Email contains (list1.Contact__r.ContactEmail)]
Can this be done?
Any help is much appreciated.
Thanks
list1 = [Select Contact__r.ContactEmail from Registrations__c Id in : lstRegistrations]
List<String> emails = new List<String>();
if(list1.size()>0){
for(Registrations__c r : list1){
emails.add(r.Contact__r.ContactEmail);
}
}
if(emails.size()>0){
list2=[Select Email from Site__c where Email IN: emails]
}
else{
//error message
}