I have a table of names that have done something on a certain date, now this could be over and over again yet of course on different dates but never the same. I need to update a field called last_time that corresponds to the previous date that they occur and update the last_time with a sum of 2 other fields,
Quick example Table
id , date , name , score, holes, last_time
1, 2015-01-01, him 1, 80, 18, (NULL)
2, 2015-01-01, him 2, 79, 18, (NULL)
3, 2015-01-01, him 3, 45, 18, (NULL)
4, 2015-01-02, him 1, 79, 9, (NULL)
5, 2015-01-02, him 2, 50, 9, (NULL)
6, 2015-01-02, him 3, 20, 9, (NULL)
7, 2015-01-03, him 1, 50, 18, (NULL)
8, 2015-01-03, him 2, 40, 18, (NULL)
9, 2015-01-03, him 3, 90, 18, (NULL)
Of course singularly and on the same id would be
update exampleTable set last_time = (score / holes) where name ="him 1"
But I need from the previous dates info.
For example I would need to update last_time on id 1 with id 4 score / holes, then id would be need last_time updating with id 7 score / holes. This table has about 100000 rows in and each date could have differening number of people taking part of course all with different names, with this I need to get the info for each person of course if they occur more than once.
I hope someone can help wit this, Im reallly struggling.