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
nagamalli tadikondanagamalli tadikonda 

Write single query to get the asociated data

3objects like object1,object2& object 3 having relationship like object 1 &2 are lookup relatin and object 2& 3 have mastr relation write single query to get the asociated data
Rahul_kumar123Rahul_kumar123
Hi Nagamalli Tadikonda,

please check the salesforce documentation on  "SOQL Relationship Queries" check below link.

https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html


Basic Examples of SOQL RELATIONSHIPS 

Child > Parent (Standard Object)
 
Select id,Account.Name,Account.Phone,Account.industry,Account.Type,Account.Rating,Account.website,Account.Ownership,Account.AnnualRevenue,
Account.NumberOfEmployees,Account.CleanStatus from Contact

Child >Parent(Custom Object)
 
Select id,COLLEGE__r.Name,COLLEGE__r.Contact__c,COLLEGE__r.Count__c,COLLEGE__r.Highest_Marks__c,COLLEGE__r.Address__c from Studnt__c

Parent >Child(Standard object)

 
select Name, Industry, (select AssistantName, Email from contacts)from ACCOUNT
Parent >Child (Custom Object)
 
select id,Name,(select Studnt__c.name__c from Studnts__r) from College__C



I hope it will be helpful.

Please mark it as solved.so they removed from unanswered questions.and more appear as the proper solution to similar kind of issue.

Best Regards
RahulKumar