Write a SOQL query to fetch Accounts that have NO related Contacts (Anti-Join using WHERE Id NOT IN (SELECT AccountId FROM Contact)).
Answer
Use an anti-join: WHERE Id NOT IN (SELECT AccountId FROM Contact).
soql
SELECT Id, Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Contact)
Returns Accounts with no Contacts. Note the subquery results are limited by the platform for semi/anti-joins, and AccountId is a lookup so the clause is valid.
soqlscenarioanti-join