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
ChinnoduChinnodu 

How to fetch the all contacts without Account using soql

Hi All,

i want  all contacts without Account using soql , how we can achive this using soql 
AbhishekAbhishek (Salesforce Developers) 
Accounts that DO NOT have any Contacts:


Select Id, Name From Account Where Id NOT IN (Select AccountId From Contact)


Accounts that do have at least 1 Contact:


Select Id, Name From Account Where Id IN (Select AccountId From Contact)

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Abhishek BansalAbhishek Bansal
Hi Chinnodu,

You can use the below SOQL to query all the contacts that do not have account:
Select Id from Contact where AccountId = Null

Let me know if you need any other help or information on this.

Thanks,
Abhishek Bansal.