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
Bhart KumarBhart Kumar 

Can we query or make report on 3 objects if one of them is lookup for other 2 but they are not related to each other?

Suppose 3 objects are A, B, and C.

A is lookup on B and also on C. This means we can query like 

Select id from B__c where and
Similarly  Select id from C__c where and

Can we somehow query all 3 in one or extract fields for all 3 in one report?


Best Answer chosen by Bhart Kumar
Hi Bhart kumar,
In this usecase A is the Parent for B and C Right.. which is LookUP relation.

So coming to Custom Objects writing QUERY at one place on three Objects A,B,C..

Try to change this Solution as per your requirement here Teacher__c is Lookup for both Student__c and Parent__c. 

Query for on 3 objects at one place.

SELECT Id,Overall_credits_Scored__c,(SELECT Id,Student_Credits__c FROM Students__r),(SELECT Id,Credits_from_Parents__c FROM Parents__r) FROM Teacher__c

If Found Helpful.,
Kindly Mark It as a Best Answer.

Thanks in Advance,