table REGISTRERINGER:
columns:
id (autoincrement)
employeeID
orderNr
regStart
regStop
Function:
When an employee adds a record using a form the new form will look like this:
XX | 1234 | 54321 | NOW() | NULL |
If the _SAME_ employee adds a new record (1234) regStop will be updated with NOW() on the previous record to 'close' it, and the new record will be inserted liked..
XY | 1234 | 64283 | NOW()| NULL |
:-/ Now.. this works fine untill i start having more than one employee adding records..
any help on such a query? what i have now is something like..
SELECT registreringer.employeeID, registreringer.regStop
FROM registreringer
WHERE (((registreringer.employeeID) In (SELECT [employeeID] FROM [registreringer] As Tmp GROUP BY [employeeID] HAVING Count(*)>1 )) AND ((registreringer.regStop) Is Null))
ORDER BY registreringer.employeeID;
But now this returns two.. so when i updated regStop based on that, i'll close 2x rows. (for 2 employees, instead of just closing the employee adding a new record)