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
Saumya SumanSaumya Suman 

Need some help in this?

Child to parent soql query and parent to child soql query on standard object?
Akshay_DhimanAkshay_Dhiman
Hi Saumya Suman

parent to child SOQL query on the standard object:
    Select Id, Name, (Select Id, LastName from Contacts) FROM Account

Child to parent SOQL query on the standard object:
    Select Id, LastName, Account.Name from Contact
    
    
and    
Parent to child SOQL query on custom object: 
      Select Id, Name, (Select Id, Name from Custom_Object2s__r) from Custom_Object1__c
   
Child to parent soql query on custom object:

      Select Id, Name, Custom_Object1__r.Name from Custom_Object2__c
   
 if this answer is helpful for you. Please choose the best answer    
    
    
Thanks 
Akshay