문제

I have the following simple query which shows I can access the field I want to filter by:

SELECT Id, Name, (SELECT HC4__IsSearchableExternally__c FROM Contacts)
FROM Account

However, what I really want to do is return only the Id and Name properties for Accounts that have at least one Contact where HC4__IsSearchableExternally__c is true. Is this possible to do with a Salesforce query?

Basically, I want to do something like the following (nonfunctional query):

SELECT Id, Name
FROM Account
WHERE (SELECT COUNT(Id) FROM Contacts WHERE HC4__IsSearchableExternally__c = true) > 0

Thanks for any help you can provide!

도움이 되었습니까?

해결책

You can do this with a semi-join, e.g:

select id, name from account 
where id in (select accountId from contact where HC4__IsSearchableExternally__c = true)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top