+ 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