yes Naval your correct but small modification is innser query is return contact id's but outer query expeting account id's so query should be like bellow.
SELECT id FROM Account WHERE id Not IN (SELECT Accountid FROM Contact WHERE Accountid !=null)
yes Naval your correct but small modification is innser query is return contact id's but outer query expeting account id's so query should be like bellow.
SELECT id FROM Account WHERE id Not IN (SELECT Accountid FROM Contact WHERE Accountid !=null)
SELECT id FROM Account WHERE id Not IN (SELECT Accountid FROM Contact WHERE Accountid !=null)
Inner query also should be return Accountid.
Thanks Naval.
All Answers
from your query i am getting all accounts, those accounts have relation with contacts or not like all accounts.
but my question is i want to get the accounts which is not have relation with contact ?
I hope this can be clear..
You are asking to query the number of contacts without AccountId rite..?
Thanks,
Vijay
Use the below query to find the contact records without account.
Select Id, Name, (Select Id, Name from Contacts where AccountId = NULL) from Account
Thanks,
Vijay
Hi Boyapati,
Use the following query.
[SELECT Id FROM Account WHERE Account Id Not In (SELECT Id FROM Contact WHERE AccountId != Null)]
Let me know if this works for you.
SELECT id FROM Account WHERE id Not IN (SELECT Accountid FROM Contact WHERE Accountid !=null)
Inner query also should be return Accountid.
Thanks Naval.