mysql> SELECT CONCAT("Calculated difference between id ",t1.id," and id ",t2.id," is ",TIMESTAMPDIFF(SECOND,t1.time,t2.time)," seconds") AS difference FROM example AS t1, example AS t2 WHERE t1.id<t2.id AND t2.id=(SELECT MIN(id) FROM example WHERE id>t1.id LIMIT 5) ORDER BY t1.id LIMIT 5;
+-------------------------------------------------------------+
| difference |
+-------------------------------------------------------------+
| Calculated difference between id 1 and id 3 is 1161 seconds |
| Calculated difference between id 3 and id 4 is 13 seconds |
| Calculated difference between id 4 and id 5 is 11 seconds |
| Calculated difference between id 5 and id 6 is 1161 seconds |
| Calculated difference between id 6 and id 7 is 2 seconds |
+-------------------------------------------------------------+
5 rows in set (2.25 sec)