function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sultansultan 

If three child objects related to one parent then how to write a Query to access all data of three child objects which is related to one parent?

anil savaliya 11anil savaliya 11
Hey Raju,

Select Id,Name ,(select id,name from child1__r),(select id,name from child2__r),(select id,name from child3__r), from parent__c

child API ,you can find from look field in detail object field and add __r after that.

Thanks,
Anil Savaliya
James LoghryJames Loghry
Using SOQL subqueries, similar to the example below:

[Select 
    Id,
    (Select Id From Children1__r)
    ,(Select Id From Children2__r)
    ,(Select Id From Children3__r) 
 From 
    Parent]

See here for more information on SOQL relationship queries: http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm

T
o find the API name for the child relationships, here's a tip:
  1. Go to Setup->Customize or Setup->Create->Objects depending on custom or standard object.
  2. Go to the fields of that object
  3. Click on the lookup or master / detail to the Parent object.
  4. Look at the Child Relationship name.  
  5. If it's a custom relationship, add a suffix of __r to the end of the relationship name.
  6. If the field is a managed package, then add a prefix of namespace__ before the relationship name.
Cloud_forceCloud_force
see if this helps you: http://www.forcexplore.com/2014/07/relationship-query-in-salesforce.html