I know I can SELECT descending to get the latest results.
But if my records end at 155 how do I separately get 150, 151, 152, 153, 154 and 155?
For 155 I can say DESCENDING LIMIT 1 but next time when I want record 154 how do I get DESCENDING LIMIT 2 but only use record 154 and not use 155?
use an offset:
limit 1 offset 2;
limit 1 offset 3;, …
the syntax for mysql defers.
Do you mean to get the last x number of rows EXCEPT the last one where you don’t know the index/id/key of the last one? Only way I can think of doing it would be to sub-query it
This example is using the sample fiddle on SQLFiddle with a couple records added to the recordset
FROM `docs` a
WHERE a.id < (SELECT MAX(id) FROM docs)
ORDER BY a.id desc
Thanks guys - chorn thanks for the coding.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.