A simple question: consider these two List queries:

List<Account> actList = [SELECT Id, (Select Id from Orders) FROM Account];

List<Account> actList = [SELECT Id, (Select Id from Quotes) FROM Account];

The first works fine, as for the second I keep getting an error message indicating that the relationship name "Quotes" is not recognised. I can't seem to find the right relationship name to use, although there's a lookup relationship from the Quote Object to account. I've tried appending __r as well as writing Quote in singular but to no avail. Please help if you know the relationship name, or suggest a better way to go about getting the child quote records of an account.

1 Answer 1


It's a little weird that between Account and Quote there is no ChildRelationship name assigned.

enter image description here

On Opportunity

enter image description here

Although if you query Quotes you have AccountId to filer by Account while for the opportunity and Quote you have "Quotes" as ChildRelationship name.

Hence you will need either query on Quote directly or query opportunity and include fields like the opportunity.AccountId to fetch accountId

The below query works

SELECT Id, Opportunity.AccountId, (Select Id from Quotes) FROM Opportunity
  • 1
    this is weird; I see same thing in Workbench. It's for stuff like this that we have the StackExchange guild to stay on top of the idiosyncrasies.
    – cropredy
    Jul 30, 2016 at 4:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .