I am trying to create a SOQL statement like this:
SELECT Lookup__c
FROM Reference__c
WHERE Type__c = 'Country - Country Code'
AND Return__c IN
(SELECT Linked_Address__CountryCode__s
FROM Timeline__c
WHERE Client__c = ':Id'
AND ELS__c = TRUE
AND Status__c != 'Closed')
When I run it in the developer console (with a hardcoded Id of course) I get an UNKNOWN_EXCEPTION error. I have tried running both parts of the query separately and that works (the nested query returns 'GB', and when I hard code that into the outer query it returns 'United Kingdom' as expected), but when I combine them it doesn't. Can anyone tell me what I am doing wrong here?
Help -> Preferences
and check the box toEnable Query Plan
. It changes between True/False and a checkbox when you try to change it. ClickSave
. The Query Editor tab will then show you theQuery Plan
button, which will give you more information about what is wrong with the query.Client__c = ':Id'
part is wrong (we can't do any variable binding in the dev console's query editor), or that your semi-join isn't working on relationship fields (semi-joins only work for relationship fields) or that the semi-join is returning an Id for an SObject other than the one thatReturn__c
is for.Client__c = :bindingname
- no quotes around the binding reference. What did you actually change the syntax to when using the dev console?