{"id":"c54922d6-87ee-45d4-86e4-e418e0b50797","task":"Run SOQL parent-to-child and child-to-parent relationship queries via the Salesforce REST Query API","domain":"salesforce.com","steps":["For child-to-parent (many-to-one) traversal, use dot notation in the SELECT clause: SELECT Id, Account.Name FROM Contact WHERE Account.Industry = 'Technology'.","For parent-to-child (one-to-many) sub-queries, embed a SELECT inside the FROM clause: SELECT Id, Name, (SELECT Id, CloseDate FROM Opportunities) FROM Account.","GET or POST to /services/data/vXX.0/query?q={URL-encoded SOQL}; use POST /services/data/vXX.0/query for long queries that exceed URL length limits.","The response includes 'totalSize', 'done', and 'records'; if 'done' is false, follow 'nextRecordsUrl' to paginate until done is true.","For sub-query results, each parent record's sub-query results are nested under the relationship name with their own 'records' array and 'done'/'nextRecordsUrl' if the child result set is large.","Use LIMIT and OFFSET or cursor-based pagination (nextRecordsUrl) rather than OFFSET alone for large datasets, as OFFSET beyond 2,000 is not supported."],"gotchas":["Parent-to-child sub-queries are limited to one level of nesting — you cannot nest a sub-query inside a sub-query.","SOQL does not support full outer joins; a child-to-parent traversal that references a null parent returns null for the parent fields, not an error — filter explicitly if nulls cause downstream problems.","The query API is synchronous and subject to a 120-second timeout; for very large result sets, use Bulk API 2.0 query jobs instead."],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/c54922d6-87ee-45d4-86e4-e418e0b50797"}