Trigger
Trigger MileageTrigger on Mileage__c (before insert, before update) {
Set<ID> ids = Trigger.newMap.keySet();
List<User> c = [SELECT Id FROM user WHERE mileageid__c in :ids];
}
Apex
for ( List<contact> contacts : [SELECT Id FROM Contact] {
for (Contact aContact : contacts) {
//modify aContact
}Database.update(contacts);
}