I wonder if SOQL ever support multiple fields in WHERE subquery... Something like this (hope, it's self-explanatory):

select whatever from Table1
where (Field1, Field2) in (select Field3, Field4 from Table2)

trying to match tuples in tables.

Or maybe a workaround is possible, like:

select whatever from Table1
where Field1 + "." + Field2 in (select Field3 + "." + Field4 from Table2)

In my case, Table1 and Table2 are not related. So far, I'm just creating the query dynamically but I wonder if the single static SOQL query would help solving the problem.

1 Answer 1


The WHERE clause does support multiple fields, but they must be listed individually. And As for joins, you can only select Id fields (be it the record's own Id or a relationship).

SELECT Fields__c FROM MyObject__c
WHERE Lookup1__c IN (SELECT Id FROM OtherObject__c)
AND Id IN (SELECT Lookup__c FROM Child__c)
  • Thanks for update but unfortunately, in my case would yield records in output that don't match. E.g., (Field1, Field2) combos going like (1, 2), (2, 3) in Table2. Your approach will match (1, 3) though it shoudn't. May 18, 2020 at 15:15
  • You have to do that in post filtering, casting a wide net with your query that you then trim to fit.
    – Adrian Larson
    May 18, 2020 at 17:00

You must log in to answer this question.

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