Last active
August 29, 2017 13:46
-
-
Save johndstein/9303136da912849f9ff72059a76be3b8 to your computer and use it in GitHub Desktop.
APEX SOQL equal and in both work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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