I have a server that adds several records to a DB on each visit. The server did it between 2-5 records for each visit. All the data between is the same expect the timestamp. I want to keep only 1 record per visit. And delete the other records.

Before:

+----+----------------------+------+--------+ | id | timestamp | user | action | +----+----------------------+------+--------+ | 1 | 01-01-01-16 03:02:05 | 5 | visit | | 2 | 01-01-01-16 03:02:06 | 5 | visit | | 3 | 01-01-01-16 03:02:05 | 6 | watch | | 4 | 01-01-01-16 03:02:06 | 6 | watch | | 5 | 01-01-01-16 03:04:05 | 9 | visit | | 6 | 01-01-01-16 03:04:06 | 9 | visit | | 7 | 01-01-01-16 03:04:07 | 9 | visit | | 8 | 01-01-01-16 03:04:35 | 2 | see | +----+----------------------+------+--------+

Expected Results:

+----+----------------------+------+--------+ | id | timestamp | user | action | +----+----------------------+------+--------+ | 1, | 01-01-01-16 03:02:05 | 5 | visit | | 3, | 01-01-01-16 03:02:05 | 6 | watch | | 4, | 01-01-01-16 03:02:06 | 6 | watch | | 5, | 01-01-01-16 03:04:05 | 9 | visit | | 8, | 01-01-01-16 03:04:35 | 2 | see | +----+----------------------+------+--------+

In other words: As you see, line 1,2 are identical. same user, and only one seconds between. So I delete line 2. Line 4 I'm not touching because it is not a visit