0

I have some custom fields on Account and a custom object with some custom fields.

i want to find id from my custom object and id of accounts that have the same field value

I tried something like:

select Id, (SELECT Id FROM Account 
WHERE My_Field__c = My_Custom_Object__c.My_Field__c) FROM My_Custom_Object__c

I also tried

select Id, (SELECT Id FROM Account 
WHERE Account.My_Field__c = My_Custom_Object__c.My_Field__c) FROM My_Custom_Object__c

I get Unknown error parsing query

I need to get this in a single SOQL query so i can get it via iOS Mobile SDK through the API, without writing my own Apex (and avoiding the two queries, because also i'd have to group results and i may easily exceed the 50K governor limit).

1 Answer 1

0

It's not possible to join on arbitrary fields. The only fields which support joins in SOQL are relationship fields (Lookup and Master-Detail).

3
  • Do you happen to maybe have some official documentation that states that this is not possible? Need it for management conversations...
    – zaitsman
    Commented May 28, 2019 at 4:13
  • 1
    There used to be an awesome guide to SOQL joins I would link people to, but it got moved a few months back and I haven't been able to track down its new location.
    – Adrian Larson
    Commented May 28, 2019 at 4:19
  • @AdrianLarson success.salesforce.com/ideaView?id=087300000006tju ...?
    – sfdcfox
    Commented May 28, 2019 at 4:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .