Five Levels of Parent-to-Child Relationships in SOQL Queries
SOQL now supports relationship queries that traverse up to five levels of parent-child records.
Use a single SOQL query to get parent-child records from five different levels.
This ability is limited to SOQL queries via the REST and SOAP query calls on standards and custom objects.
This feature is supported In API version 58.0 and later, SOQL relationship queries can contain a parent root as the first level of the query and child relationships up to four levels deep from the parent root.
This example SOQL relationship query returns records from the parent object Account and its child objects Contacts, Assets, WorkOrders, and WorkOrderLineItems.
SELECT Name,
(SELECT LastName,
(SELECT AssetLevel,
(SELECT Description,
(SELECT LineItemNumber FROM WorkOrderLineItems)
FROM WorkOrders)
FROM Assets)
FROM Contacts)
FROM Account
SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.
ReplyDelete