Skip to content

Instantly share code, notes, and snippets.

@dancinllama
Created January 16, 2015 22:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancinllama/2bfa01a863caa128cb91 to your computer and use it in GitHub Desktop.
Save dancinllama/2bfa01a863caa128cb91 to your computer and use it in GitHub Desktop.
SOQL parent relationship query
List<Account> parentAccounts = new List<Account>();
for(Contact contactWithAccountInfo : [Select Name,Account.Name,Account.AnnualRevenue From Contact]){
System.debug('Contact Account Id: ' + contactWithAccountInfo.Account.Id);
parentAccounts.add(contactWithAccountInfo.Account);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment