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

Compare two lists
Hi all,
I think my brian is fried as I have been coding all day - I don't even know if I am searching using the correct terminology as I have been jumping between SQL, SOQL, APEX & VB all day...
Essentially looking to see if it is possible to compare the results a list collection to the results in another list.
As an example - list 1 is generated from the following code:
list<recordType> rT = list<Recordtype>(SELECT ID FROM RecordType WHERE (Name LIKE '%Standard%' OR Name LIKE '%Parent%') AND sObjectType = 'Account');
List 2 is a list of all accounts:
list<Account> ac = list<Account>(SELECT Id, RecordTypeID FROM Account);
I know with SOQL you can have a nested query, though in using the 'Database.getQueryLocator' method I seem to be unable to use nested SOQL statements for my batch code...
Make them into the same type, and then use containsAll() method in the Set to compare, doc,
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_set.htm
All Answers
Make them into the same type, and then use containsAll() method in the Set to compare, doc,
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_set.htm
Fantastic - thank you very much!