Skip to main content

Posts

Showing posts with the label using NOT IN in salesforce

NOT IN Keyword in Soql in Salesforce.

Suppose there is a requirement to fetch all accounts record which don't have any contacts, how will we do it? We can fetch account with their corresponding contact record in a in line query. for example list<Account> listOfAccounts = [SELECT id, Name,                                                  (SELECT id,name FROM Contacts)                                                   FROM Accounts]; list<Account> accountListwithoutContact = new list<Account>(); for(Account act :listOfAccounts ){       if(act .Contacts !=null && act .Contacts.size() !=0){               accountListwithoutContact.add(act)   ;       } } accountL...