Activity Forums Salesforce® Discussions Is there any way to define more than 1 SOQL quires in a batchable class start method in Salesforce?

  • Piyush

    Member
    August 21, 2019 at 3:41 am

    Hi Deepak,

    if you are want to query the same object type but with multiple different WHERE selection clauses, and you then want to just apply the same logic to them, this is a simple matter of appropriately parenthesizing and combining the clauses into a single WHERE.

    For example, if your first query is looking for instances matching:

    A__c = '123' AND B__c = 'xyz'

    while your second query is looking for instance matching:

    A__c = '987' AND (B__c = 'abc' OR C__c = 999)
    then you can construct your query as:

    SELECT Id, ... FROM MyObject__c WHERE
    (A__c = '123' AND B__c = 'xyz') OR
    (A__c = '987' AND (B__c = 'abc' OR C__c = 999))

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos