0

As far as I know to select last 7 rows from MySQL table in backward order, it needs to be done:

SELECT * FROM `table`
ORDER BY id DESC
LIMIT 7;

But I want to select penult 7 rows. After that I want to select 7 rows, except 14 last rows, etc...

Thereby, I wonder what sql query it should be to select 7 rows, except last N * 7 rows?

Kurowsky
  • 154
  • 1
  • 9
  • 2
    Hint: `limit`, `offset`. – Gordon Linoff Jan 21 '21 at 02:20
  • Last or First is purely base on order, so I think you want to select X rows from table but do not select ***The 7N rows***? – T. Peter Jan 21 '21 at 02:22
  • Yes, select X last rows without 7*N last rows – Kurowsky Jan 21 '21 at 02:26
  • 1
    Does this answer your question? [MySQL Data - Best way to implement paging?](https://stackoverflow.com/questions/3799193/mysql-data-best-way-to-implement-paging) Specifically [this answer](https://stackoverflow.com/a/3799293/14868997), which shows how to do keyset paging – Charlieface Jan 21 '21 at 03:01

0 Answers0