ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Soql questions28 of 30
SoqlEasy 1 min read

How do you write a Child-to-Parent query on Standard Objects vs Custom Objects (__r)?

Asked atTCSWiproTech Mahindra

Answer

Use dot notation on the relationship name.

  • Standard lookup: relationship name is the field name without Id, e.g. Account for AccountId.
  • Custom lookup/master-detail: field Department__c becomes Department__r.
soql
SELECT Name, Account.Name, Account.Industry FROM Contact
SELECT Name, Department__r.Name, Department__r.Manager__r.Name FROM Employee__c

Standard: Account.Name; custom: Parent__r.Name.

soqlrelationshipschild-to-parent
Practice SOQL & Apex
PreviousHow do you write a Parent-to-Child subquery on Standard Objects (Contacts) vs Custom Objects (Employees__r)?Next What are the key differences between SOQL and SOSL, and when do you choose one over the other?

More Soql questions

  • How do you query Custom Metadata Types (getAll(), getInstance()) without consuming SOQL governor limits?
  • How do you query Big Objects using SOQL vs Async SOQL, and why must you query indexed fields in exact order?
  • What is the governor limit for Aggregate queries and how do rows counted in AggregateResult contribute to the 50,000-row limit?
  • What are the Governor Limits for SOQL (100 synchronous queries, 200 asynchronous queries, 50,000 total rows retrieved)?
  • Which fields are indexed by default in Salesforce, and what makes a SOQL filter non-selective (e.g., !=, NOT LIKE '%abc', leading wildcards, formula fields)?