# Write a SOQL query to fetch all Accounts along with their related Contacts (Parent-to-Child).

**Topic:** Development · **Difficulty:** Easy · **Asked at:** TCS, Wipro, Infosys · **Tags:** soql, scenario, parent-to-child

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-to-fetch-all-accounts-along-with-their-related-contacts-parent-to-child

## Answer

Use a parent-to-child subquery with the child relationship name.

```soql
SELECT Id, Name, (SELECT Id, FirstName, LastName FROM Contacts) FROM Account
```
Accounts with no Contacts are still returned (with an empty child list), unlike an inner join.

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