Skip to content

Instantly share code, notes, and snippets.

@johndstein
Last active August 29, 2017 13:46
Show Gist options
  • Save johndstein/9303136da912849f9ff72059a76be3b8 to your computer and use it in GitHub Desktop.
Save johndstein/9303136da912849f9ff72059a76be3b8 to your computer and use it in GitHub Desktop.
APEX SOQL equal and in both work
// Maybe everyone already knew this, but equal and in both work for collections
// in APEX.
Account_Team__c[] ats = [select Id, Account__c from Account_Team__c limit 3];
Set<Id> accId = new Set<Id>();
for (Account_Team__c at : ats) {
accId.add(at.Account__c);
}
Account_Team__c[] accTeams = [
SELECT Account__c, Role__c, User__c
FROM Account_Team__c
WHERE Account__c = :accId // THIS WORKS
];
System.debug(accTeams);
accTeams = [
SELECT Account__c, Role__c, User__c
FROM Account_Team__c
WHERE Account__c in :accId // of course this works
];
System.debug(accTeams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment