Skip to main content
Experts, I was asked a question recently that how can a Set<Id> be used to limit SOQL search results ?

I vaguely remeber all the multiple choices given .. but one of them was by using .containsAll .. have you ever seen such question or concept ? 
1 Antwort
  1. 4. Jan. 2019, 01:23
    You can use it like this

     

    Set<String> names = new Set<String>();

    names.add('Test');

    names.add('Test2');

    System.debug([SELECT Name FROM Account WHERE Name IN: names]);

    Or some think like that

     

    SET<String> cnt = new SET<String>();

    for(Contact c : [Select Email From Contact]) {

    cnt.add(c.Email);

    }

    List<Contact> contactsWithValidEmail = [Select Email From Contact Where Email IN: cnt];

     
0/9000