+ Start a Discussion
HelloSanHelloSan 

i need to pass a query to fetch the records in batch class where program picklist field on account object is equals to say X,Y,Z

the qurey is as similar as 
eg : global database.querylocator start(Database.BatchableContext BC){ 
                query = 'select id,Program__c from Account where program__c';
pconpcon
You can do
 
query = 'select id,Program__c from Account where program__c in ('X', 'Y', 'Z')';

or something more complex like
 
List<String> programs = new List<String>{
    'X',
    'Y',
    'Z'
};

List<String> queryParts = new List<String>();

for (String program : programs) {
    queryParts.add('\'' + String.escapeSingleQuotes(programs) + '\'');
}

query = 'select id,Program__c from Account where program__c in (' + String.join(queryParts, ',') + ')';

NOTE: This code has not been tested and may contain typographical or logical errors
NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.