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
doedoe 

SOQL issue

Please help in the following query

 

Child object child1 has a master detail relationship with both master1 and master2

 

The following query does not work for me

 

SELECT name FROM Child1 Where master1__r.cust1__c = master2__r.cust2__c

 

 

Best Answer chosen by Admin (Salesforce Developers) 
sornasorna

I don't think it is possible in SOQL to have right side of where clause as a field from the object. 

So, I would suggest querying all the rows, iterate them and find out the rows which has the same value for master 1 & 2. 

All Answers

sornasorna

I don't think it is possible in SOQL to have right side of where clause as a field from the object. 

So, I would suggest querying all the rows, iterate them and find out the rows which has the same value for master 1 & 2. 

This was selected as the best answer
doedoe

Thanks sorna, I would write the iterate logic  in Apex after querying all the rows