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

Joining three tables

I have three tables one is Account this standard which is related to role__c custom object. role__c. Role__c contains a look up of Account. Role__c is also related to Agreement__c where Agreement__c has also a look up for Role__c. Now I want to make a query comprising all three tables.



Select a.Status__c, a.Name, a.Id, (Select Client__c, Agreement__c, Role_Id__c From RoleAgreement__r), (Select Name, Area_Code__c, Customer__c, Phone_Number__c, Type__c, Agreement__c From Phones__r), (Select Name, Customer__c, Name_Id__c, Agreement__c From Names__r), (Select Name, Customer__c, Email_Address__c, Type__c, Agreement__c From Emails__r), (Select Name, Address_Line_1__c, Address_Line_2__c, City__c, Customer__c, State__c, Type__c, Zip_Code__c, Agreement__c,(Select Id,Name from Account) From Addresses__r) From Agreement__c a where status__c='Active' and id IN (Select  agreement__c from Role__c where client__c='<id-value>')




The query is not runnning as Agreement__c is not directly related to Account


A help will be much appreciable