How to get the last record before the last one in mysql?
database, mysql, relational-database, sql
Solution
If you know there are 35 records, you want `limit 1 offset 34`.
If you want to get the 2nd last element from any set, you can invert the order of the set and select one element, offset one element. You can implement this yourself by first selecting the first two elements of the inversely ordered set, and then reverse the set and select the first element:
select * from
(select * from my_table order by id desc limit 2) table_alias
order by id limit 1
Problem
How can I get record 34 of a table if the last record is record 35 ?