My first choice would probably be to use one of the above sentences generating a sequence number. However, with a large number of records, creating such a sequence can be slow (especially if you ignore more records).
However, another option is to make a connection. This is useless since you have 2 columns to determine which of the previous entries.
Not verified, but something like this: -
SELECT a.*, b.Time_Stamp, b.Time_stamp_ms FROM ( SELECT a.Time_Stamp, a.Time_stamp_ms, a.cycle, MAX(DATE_ADD(b.Time_Stamp, INTERVAL b.Time_stamp_ms MICROSECONDS)) AS latest_prev_record FROM mytable a INNER JOIN mytable b ON DATE_ADD(a.Time_Stamp, INTERVAL a.Time_stamp_ms MICROSECONDS) > DATE_ADD(b.Time_Stamp, INTERVAL b.Time_stamp_ms MICROSECONDS) WHERE a.cycle = 1 GROUP BY a.Time_Stamp, a.Time_stamp_ms, a.cycle ) Sub1 INNER JOIN mytable a ON a.Time_Stamp = Sub1.Time_Stamp, AND a.Time_stamp_ms = Sub1.Time_stamp_ms, AND a.cycle = Sub1.cycle INNER JOIN mytable b ON DATE_ADD(b.Time_Stamp, INTERVAL b.Time_stamp_ms MICROSECONDS) = Sub1.latest_prev_record
This can be made much simpler if you only need timestamps and other data, and if you have one combined date / time / millisecond field (you can just use the subquery). Even easier, if you had all the records that have a consistent id field (i.e., Guaranteed to be in that order).
EDIT - Simplified if you only want to return the last record before loop 1: -
SELECT z.* FROM ( SELECT a.Time_Stamp, a.Time_stamp_ms, MAX(DATE_ADD(b.Time_Stamp, INTERVAL b.Time_stamp_ms MICROSECOND)) AS latest_prev_record FROM mytable a INNER JOIN mytable b ON DATE_ADD(a.Time_Stamp, INTERVAL a.Time_stamp_ms MICROSECOND) > DATE_ADD(b.Time_Stamp, INTERVAL b.Time_stamp_ms MICROSECOND) WHERE a.cycle = 1 GROUP BY a.Time_Stamp, a.Time_stamp_ms ) Sub1 INNER JOIN mytable z ON DATE_ADD(z.Time_Stamp, INTERVAL z.Time_stamp_ms MICROSECOND) = Sub1.latest_prev_record
EDIT again.
You can add a decimal field for the combined timestamp (add an index for it) and fill it with: -
update `mytable` set `timestamp_full` = UNIX_TIMESTAMP(`Time_Stamp`) + (`Time_stamp_ms` / 1000)
then you can use the following SQL to get the required records: -
SELECT z.* FROM ( SELECT a.timestamp_full, MAX(b.timestamp_full) AS latest_prev_record FROM mytable a INNER JOIN mytable b ON a.timestamp_full > b.timestamp_full WHERE a.cycle = 1 GROUP BY a.timestamp_full ) Sub1 INNER JOIN mytable z ON z.timestamp_full = Sub1.latest_prev_record