use of for update apex salesforce code example
Example: soql update query
SOQL is a query language. It has no support for operations besides Read. If you want to perform other CRUD operations, you will need to make different calls. Within Apex, that would look like:
List<MyObject__c> records = [SELECT ... FROM MyObject__c WHERE ...];
for (MyObject__c record : records)
{
// set some fields
}
update records;