<< Prev Question

Question 54/54

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 it's trainers?

Recent Comments (The most recent comments are at the top.)

Nilesh M - Apr 09, 2023

Ans is C. SELECT ID FROM Trainer_c WHERE Gym__r.Name = ‘Viridian City Gym’

Explanation:
Since Trainer_c has a lookup field to Gym_c, we can traverse the relationship to get the Gym_c record and filter it by the Name field to get the record for the Viridian City gym. Then, we can use the child relationship name "Gym__r" to access the related Trainer_c records.

Option A is incorrect because it uses the wrong child relationship name ("Trainers__r") for the Trainer_c object.

Option B is incorrect because it incorrectly queries the child object's records first, rather than the parent object's record.

Option D is incorrect because it uses the wrong child relationship name ("Trainers__c") for the Trainer_c object.

kamaty - Feb 25, 2023

we use __r instead of __r because Trainers__c and Gym__c are related to eachother and you're trying to fetch Trainers__c from Gym__c

VenkatRao - Sep 14, 2022

SELECT id, (SELECT id FROM Trainers__r) FROM Gym __c WHERE NAME ='Viridian City gym'

Vish - Aug 15, 2022

Answer is option D, but the child object name should have the string - '__r' to specify that It has a relationship and is a child object.

Correct Answer : SELECT Id, (SELECT Id FROM Trainers__r) FROM Gym_C WHERE Name . Viridian City Gym'

TARIK - Oct 01, 2021

answer is : SELECT Id, (SELECT Id FROM Trainers__r) FROM Gym__c WHERE Name ='Viridian City Gym'

Alex - Aug 18, 2021

answer is B i think, when we use inner select with standard object we should add S like Contact Contacts, and when we use custom object in inner select we should use __r instead of __c.
i wish we get explanation

numpossofala - Jul 13, 2021

Can you please check the spelling of the answers?
thanks

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

Question List (54q)
Question 1: Which three steps allow a custom SVG to be included in a Lig...
Question 2: A developer needs to create a baseline set of data (Accounts...
Question 3: A Next Best Action strategy uses an Enchance Element that in...
2 commentQuestion 4: A developer has an integer variable called maxAttempts. The ...
2 commentQuestion 5: What can used to delete components from production?...
4 commentQuestion 6: A developer writes a trigger on the Account object on the be...
6 commentQuestion 7: A developer considers the following snippet of code: (Exhibi...
4 commentQuestion 8: A developer is asked to create a Visualforce page that displ...
Question 9: Universal Containers stores the availability date on each Li...
2 commentQuestion 10: What are two ways a developer can get the status of an enque...
1 commentQuestion 11: Universal Containers stores Orders and Line Items in Salesfo...
Question 12: A developer must troubleshoot to pinpoint the causes of perf...
Question 13: A developer has a Visualforce page and custom controller to ...
3 commentQuestion 14: A team of many developers work in their own individual orgs ...
6 commentQuestion 15: A developer needs to create a custom button for the Account ...
Question 16: Which aspect of Apex programming is limited due to multitena...
Question 17: Universal Container use a simple order Management app. On th...
Question 18: Universal Containers (UC) uses a custom object called Vendor...
Question 19: When a user edits the Postal Code on an Account, a custom Ac...
Question 20: What is the order of operations when a record is saved in Sa...
Question 21: A developer uses a loop to check each Contact in a list. Whe...
1 commentQuestion 22: How many accounts will be inserted by the following block of...
1 commentQuestion 23: Given the following Apex statement: Account myAccount = [SEL...
Question 24: The sales management team at Universal Containers requires t...
Question 25: Given the following block code: try{ List &lt;Accounts&gt; r...
3 commentQuestion 26: What is the result of the following code?...
Question 27: A developer created a Visualforce page and custom controller...
Question 28: A developer wants to import 500 Opportunity records into a s...
Question 29: A Lightning component has a wired property, searchResults, t...
Question 30: Which code displays the content of Visualforce page as PDF?...
Question 31: What are three techniques that a developer can use to invoke...
Question 32: A developer needs to save a List of existing Account records...
Question 33: How should a developer write unit tests for a private method...
4 commentQuestion 34: Given the following trigger implementation: trigger leadTrig...
Question 35: developer created this Apex trigger that calls MyClass .mySt...
1 commentQuestion 36: Which code displays the contents of a Visualforce page as a ...
8 commentQuestion 37: A developer has the following requirements: Calculate the to...
Question 38: Assuming that 'name; is a String obtained by an &lt;apex:inp...
Question 39: A developer is debugging the following code to determinate w...
3 commentQuestion 40: A developer must create a ShippingCalculator class that cann...
Question 41: Where are two locations a developer can look to find informa...
Question 42: A developer needs to confirm that a Contact trigger works co...
Question 43: The values 'High', 'Medium', and 'Low' are Identified as com...
Question 44: An org has an existing Visual Flow that creates an Opportuni...
Question 45: Which two conditions cause workflow rules to fire? Choose 2 ...
Question 46: A developer creates a new Apex trigger with a helper class, ...
Question 47: What should a developer use to obtain the Id and Name of all...
5 commentQuestion 48: Which three statements are true regarding custom exceptions ...
2 commentQuestion 49: Universal Containers has large number of custom applications...
Question 50: A developer has a requirement to create an Order When an Opp...
Question 51: A developer is creating a test coverage for a class and need...
3 commentQuestion 52: A workflow updates the value of a custom field for an existi...
Question 53: What does the Lightning Component framework provide to devel...
7 commentQuestion 54: A custom object Trainer_c has a lookup field to another cust...