Salesforce Platform Developer I (legacy) — Question 30
The Job_Application__c custom object has a field that is a Master-Detail relationship to the Contact object, where the Contact object is the Master. As part of a feature implementation, a developer needs to retrieve a list containing all Contact records where the related Account Industry is `˜Technology' while also retrieving the contact's Job_Application__c records.
Based on the object's relationships, what is the most efficient statement to retrieve the list of contacts?
Answer options
- A. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Account.Industry = 'Technology'];
- B. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Accounts.Industry = 'Technology'];
- C. [SELECT Id, (SELECT Id FROM Job_Applications_c) FROM Contact WHERE Accounts.Industry = 'Technology'];
- D. [SELECT Id, (SELECT Id FROM Job_Application_c) FROM Contact WHERE Account.Industry = 'Technology'];
Correct answer: A
Explanation
Option A is correct because it properly references the Master-Detail relationship using 'Job_Applications_r' and correctly accesses the Account's Industry field. Option B incorrectly uses 'Accounts' instead of 'Account', and C also incorrectly references 'Accounts' while using the incorrect relationship name 'Job_Applications_c'. Option D incorrectly uses 'Job_Application_c', which does not match the correct child relationship name.