You need to sign in to do that
Don't have an account?
Stephen E 4
Is it possible to grab child accounts in a single SOQL query?
For example, if I wanted to grab accounts and their contacts in a single SOQL query I could do this:
[SELECT Id,(SELECT Id FROM Contacts) FROM Account]
Is this possible to do with child accounts? (Using the Standard "Parent" field)
When I attempt this:
[SELECT Id,(SELECT Id FROM Accounts) FROM Account]
I get this error:
"Didn't understand relationship 'Accounts' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names."
Is this possible?
[SELECT Id,(SELECT Id FROM Contacts) FROM Account]
Is this possible to do with child accounts? (Using the Standard "Parent" field)
When I attempt this:
[SELECT Id,(SELECT Id FROM Accounts) FROM Account]
I get this error:
"Didn't understand relationship 'Accounts' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names."
Is this possible?
ChildAccounts is the child relationship name.
"__r" (custom) and plural (standard) are conventions but there are exceptions.
All Answers
ChildAccounts is the child relationship name.
"__r" (custom) and plural (standard) are conventions but there are exceptions.
As Alain mentioned you need to use child relationship filed to get the child records.
Try below query to get the child account.
--
Thanks,
Prashant