+ Start a Discussion
Sandeep M 1Sandeep M 1 

Soql query on parents other child object

I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC.

objectA - objectB (Master-detail relationship)
objectA - objectC (Master-detail relationship)

Now i want to retrieve records from objectC to objectB along with objectA fields. How can i achieve such functionality . any examples would help me out.
The query would be something like this. I have accounts as a master object for both Opportunities and Test333 object. To select all the records of Account + related Opportunities + Related test333 records the query would be as below

select id,(select id from Opportunities),(select id from test333__r) from account where id='001O000000MZVDG'

Note : All custom objects should be referred by __r and all standard objects should be referred with plural name. 

Hope this helps !!

Please mark this as the best answer if this resolved your issue .