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

**Topic:** Soql · **Difficulty:** Easy · **Asked at:** TCS, Wipro, Tech Mahindra · **Tags:** soql, relationships, child-to-parent

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-you-write-a-child-to-parent-query-on-standard-objects-vs-custom-objects-r

## 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`.

---
Source: ForceChallenges · last updated 2026-10-21
