nerdexam
Salesforce

PDI · Question #110

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 ne

The correct answer is B. [SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Accounts.Industry. The most efficient SOQL statement to retrieve Contacts with related Job Applications based on the parent Account's industry uses a subquery for Job Applications and correctly references the parent Account's Industry field as Account.Industry.

Submitted by dimitri_ru· Apr 18, 2026Data Modeling and Management

Question

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?

Options

  • A[SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Account.Industry =
  • B[SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Accounts.Industry
  • C[SELECT Id, (SELECT Id FROM Job_Applications_c) FROM Contact WHERE Accounts.Industry
  • D[SELECT Id, (SELECT Id FROM Job_Application_c) FROM Contact WHERE Account.Industry =

How the community answered

(32 responses)
  • A
    3% (1)
  • B
    84% (27)
  • C
    3% (1)
  • D
    9% (3)

Why each option

The most efficient SOQL statement to retrieve Contacts with related Job Applications based on the parent Account's industry uses a subquery for Job Applications and correctly references the parent Account's Industry field as `Account.Industry`.

A[SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Account.Industry =

This option incorrectly uses `Accounts.Industry` in the WHERE clause; the relationship from Contact to Account is singular, so it should be `Account.Industry`.

B[SELECT Id, (SELECT Id FROM Job_Applications_r) FROM Contact WHERE Accounts.IndustryCorrect

This query correctly retrieves Contact records whose parent Account's Industry is 'Technology' and uses the correct child relationship name `Job_Applications__r` in the subquery to fetch related Job Application records for each contact.

C[SELECT Id, (SELECT Id FROM Job_Applications_c) FROM Contact WHERE Accounts.Industry

This option incorrectly uses `Job_Applications_c` in the subquery instead of the relationship name `Job_Applications__r`, and also incorrectly uses `Accounts.Industry` in the WHERE clause.

D[SELECT Id, (SELECT Id FROM Job_Application_c) FROM Contact WHERE Account.Industry =

This option incorrectly uses `Job_Application_c` in the subquery instead of the plural child relationship name `Job_Applications__r`.

Concept tested: SOQL relationship queries (parent-to-child, child-to-parent)

Source: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships.htm

Topics

#SOQL#Relationship Queries#Master-Detail#Custom Objects

Community Discussion

No community discussion yet for this question.

Full PDI Practice