Salesforce Platform Developer I (legacy) — Question 157

A custom object Trainer__c has a lookup field to another custom object Gym__c.

Which SOQL query will get the record for the Viridian City Gym and all its trainers?

Answer options

Correct answer: D

Explanation

The correct answer is D because it uses a subquery to retrieve all Trainer__c records associated with the Gym__c that has the name 'Viridian City Gym'. Option A is incorrect as it only retrieves Trainer__c records but not the Gym__c record. Options B and C are incorrect because they either reference the wrong relationship name or do not gather the trainers correctly.