I'm trying to write a simple "undo"-system for a table with the following structure:
id element position start_date end_date 1 1 23 01/01/2015 05/01/2015 2 2 36 01/01/2015 NULL 3 1 17 05/01/2015 NULL
So, when a new action is added for an existing element, it adds a new row with the new position and the current date, and changes the end_date of the previous row of that element to the current date.
Now, to undo this, I delete the row of the element where there is no end_date defined (this is the latest action for that element), but then I have to change the end_date of the previous row to
So, in pseudolanguage, the query needed would be:
UPDATE [table] SET end_date = NULL WHERE element = 1 AND start_date = 'highest_start_date_to_be_found_of_this_element'
Question: what to type instead of
highest_start_date_to_be_found_of_this_element to make it work?