[SalesForce] How to query multiple Child object of a parent in single soql query

I have to bring the values of a multiple child object of a Parent object in single query,

I tried the following method , however for query one child object as a first step it throws me the following error:

Error: "Didn't understand relationship 'OrderTraining__r' 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."

the query is

newOrders = [select id,OrderNumber,(select Name__c from OrderTraining__r) from Order];

Please advise.

Thanks

Best Answer

Syntax is correct, check for the relation ship name OrderTraining__r.

Seems like OrderTraining is custom object, Navigate to lookup field on OrderTraining object to see the relationship name.


added more details:

enter image description here

  • If relationship name is Resources, I would use Resources__r in my subquery.