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

SOQL query on two unrelated objects
Hi,
We have two objects, one cusotm and and one OOTB and both are not related but they have one field which will have same values.
How can we build a SOQL query for this ? Is this even possible ?
Reards,
Desai
We have two objects, one cusotm and and one OOTB and both are not related but they have one field which will have same values.
How can we build a SOQL query for this ? Is this even possible ?
Reards,
Desai
Try the following code:
public class TestStringSame {
public static void check() {
List<Account> accList = new List<Account>();
Set<String> uniqueFieldSet = new Set<String>();
List<OtherObject__c> OtherObjectList = new List<OtherObject__c>();
accList = [SELECT Id, uniqueField__c FROM Account WHERE uniqueField__c != null LIMIT 10000];
for(Account a : accList) {
uniqueFieldSet.add(a.uniqueField__c);
}
if(uniqueFieldSet.size() > 0) {
OtherObjectList = [SELECT Id, uniqueField__c FROM OtherObject__c WHERE uniqueField__c In: uniqueFieldSet LIMIT 10000];
}
system.debug('----' + courseList);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi