Activity Forums Salesforce® Discussions How to use IN clause in Dynamic query? Reply To: How to use IN clause in Dynamic query?

  • Vivek

    Member
    July 23, 2017 at 10:02 am

    It is very simple assume you have a Set<String> or Set<Id> named "ids"

    Set ids = new Set();

    String dynamicQuery = "SELECT ID FROM SomeObject__c WHERE SomeID IN :ids";

    Database.query(dynamicQuery);

    You don't have to do anything when complier will compile the code it will find set of ids and put it into your query