+ Start a Discussion

SOSL Child query question

Contact is a child of Account.


There are plenty of examples of getting Contacts from an Account. Is there an SOSL query that could tell me whether or not an Account has any Contacts? How can I quickly determine if an Account has not Contacts? If I were doing SQL, I would do something like this:

select account.id from account where account.id not in (select contact.accountid from contact)



Assuming you really mean SOQL and not SOSL, you can do


select id from account where id not in (select accountId from contact)


to get all the accounts with no contacts


Yes, I meant SOQL. And your suggestion worked. Thanks.