How to query those Account which has not any related Contacts ? I have Queried Account and contact in inner query. I found All Account with that Account I looped and find those Account whose Contact equals Null. But I want, can it be acheive by query only no need to loop over Acccout . Please Help
1 Answer
This query will give you accounts that DO NOT have any contacts.
Select Id, Name From Account Where Id NOT IN (Select AccountId From Contact) On the flip, you can query all Accounts that do have at least 1 contact like this
Select Id, Name From Account Where Id IN (Select AccountId From Contact) - No problem, glad to help :)Chris Duncombe– Chris Duncombe2015-08-31 14:59:10 +00:00Commented Aug 31, 2015 at 14:59