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
RasmiRasmi 

SOQL join

Hi,
 
I want to write a query in this way
SELECT Id, Name__c FROM SubCategory__c where CategoryId__r.Id IN (SELECT Id FROM EmissionCategory__c where SourceId__r.Id ='a0N80000000d496EAA')
 
but IN is not working fine.
I want to avoid the for loop.
Can anyone suggest me how shall i proceed
 
RickyGRickyG
Rasmi -

The doc on the new semi-join feature states that the left hand operand "must be a single primary ID field".  My guess is that your problem is using a field that is an ID field in a related object. 

You can always do this by assembling a string variable and using that, though.

Hope this helps.
SuperfellSuperfell
I don't know if this'll actually address your problem but in general CategoryId__c is preferable to CategoryId__r.Id (same for sourceId__c/r)