Thursday, 20 April 2017

How to calculate if table rows are inserted consecutively in MySQL



As a Developer, I'm often working with asynchronous code, code that isn't well  synchronous be that with workers or events, sometimes this means the created time is out of order and to report on it we need to validate the created date time.

SELECT @a := 0;
SELECT invid, `date`, `date` - @a AS gap, @a := `date`
FROM INVOICES AS i
HAVING gap < 0

No comments:

Post a comment