public class test1234{ public static void main1(){ /* List ol = new List(); for(Integer i=1;i<=5;i++){ Opportunity opl = new Opportunity(); opl.Name='test'+i; opl.StageName = 'Prospecting'; opl.CloseDate=Date.today(); ol.add(opl); } insert ol;*/ // First, query for the opportunities you want to update List oppsToUpdate = [SELECT Id, Name,StageName FROM Opportunity WHERE Name = 'Today1' OR Name='Today2']; system.debug('@@@@ reocrds'+ oppsToUpdate); // Then, make the changes to the records for(Opportunity opp : oppsToUpdate) { opp.StageName = 'Closed Won'; } // Finally, update the records in the database update oppsToUpdate; } }