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
HarishGoudd BuuraHarishGoudd Buura 

Querying Related LIst

Hello, 

Please let me we have to query all the contacts records which are not having any related list(child OBJS) , 
We have to delete those contacts, 
we have 18 child objects for contact. 
Thanks in avdacne 
YuchenYuchen
I think you can do something like this:
SELECT id, name from Contact where id not in (select contactid from Case)

The above is just an example for the Case related list, then you can append all the 18 child objects in the query to find out the contacts which are not having any related list. So it will be like:
SELECT id, name from Contact where id not in (select contactid from Case) and id not in (select contact__c from XXX) and id not in ...
 
HarishGoudd BuuraHarishGoudd Buura
Hellow Yuchen,
Thanks for your reply and here I'm facing an Error "Maximum 2 semi join sub-selects are allowed"
I can apend more than 2 semi joins here please let me know is there any other way to get the records