I need to frame a SOQL in such a way that, from child i have to get the parent name and then i also need to get some data of another child of the same parent.
Example :
I have 3 objects
Invoice
Subscription
Billing Account.
Invoice (Child) ——> Billing Account (Parent)
Subscription (Child) ——-> Billing Account (Parent)
From Invoices , i needs to get the information of Subscription via Billing Account .
Please find the query i framed
select Name,UM_Billing_Location__r.Name,UM_Billing_Location__r.csconta__Account__r.Name,(select Name from UM_Billing_Location__r.csord__Subscription__r) from UM_InvoiceHeader__c
I dont think so this part is correct
(select Name from UM_Billing_Location__r.csord__Subscription__r)
Kindly help
Thanks
Best Answer
Not entirely clear about your question. This answer assumes you have two child objects of one parent object.
From A Deeper look at SOQL and Relationship Queries on Force.com you need a
Left Outer Join
and aLeft Inner Join
, shown below:You can add
where
,order by
andlimit
as needed to theChild2__c
part of the query.