I just made a query to get second last row from database:
Here Is code:
SELECT TOP 1 * FROM (select Top 2 * from Categories ORDER BY CategoryID DESC)x ORDER BY CategoryID
but this code gives me error syntax error in new version.
In older version this code work fine.
What is problem: I have 10 results in the table, and when I submit this query, it gives me 9 row. But when 9 row delete from table, now I have 8 and 10. But this code gives me 10.
Advertisement
Answer
SELECT * FROM Categories ORDER BY CategoryID DESC LIMIT 1,1