select max id minus one ( second last row id )

mysql

Solution

You can use: EDIT: (added Bill's suggestion which is better)

SELECT (`EventID`) FROM 'event' ORDER BY 'EventID' DESC LIMIT 1 OFFSET 1

OR:

SELECT `EventID` FROM (SELECT (`EventID`) FROM 'event' ORDER BY 'EventID' DESC LIMIT 2) ORDER BY 'EventID' ASC LIMIT 1

This solution is more general and will also work if your EventID column has gaps

Problem

Just wondering if there is a simple query that I could use to get the second last record when selecting max id. ``` SELECT MAX(`EventID`) FROM `event`; ``` Thank you

Original source

Related problems