function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
emacadieemacadie 

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)

 

SuperfellSuperfell

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

emacadieemacadie

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