I am having a button on a site for "next page" which links to the next page with an item that is older then the one displayed. Then there is a counter (4/10), showing the position.
This dataset will fail on my approach:
date_created
2018-11-27 22:31:11
2018-11-27 22:31:11
2018-11-27 22:31:12
2018-11-27 22:31:12
2018-11-27 22:31:12
2018-11-27 22:31:12
2018-11-27 22:31:13
2018-11-27 22:31:14
Getting next URL works as I am also using ID:
SELECT URL
FROM items
ORDER BY ca.date_created ASC, ca.ID ASC LIMIT 1
The item position failes and is calculated like this:
SELECT count(ID) AS c
FROM table
WHERE date_created > '2018-11-27 22:31:10'
How could I alter the logic or the SQL to show the correct position from the current item on? I am using MySQL.
SELECT count(ID) AS c
FROM table
WHERE date_created > '2018-11-27 22:31:10'