Is "LIMIT $n,1 MOD $m" possible in mysql?
Posted by:
Markus M.
Date: May 27, 2015 09:20PM
Hi,
I'd like to select from a table like this (the following is just an example):
The table has 4 rows.
There's an $index in PHP. It counts 0, 1, 2 3, 4, 5 ...
For $index 0 to 3 I want to fetch rows 0 to 3. But for $index = 4, 5 etc I want to fetch again rows 0, 1 etc.
So, this would be possible with an auto-incremented id field, and I'd do $index % 4 and use that to fetch the id i'm looking for.
But that table with an auto-incremented field would become sparse, as soon as I remove rows later, and I have to remove rows somewhen, it's about user content filtered by an admin. And I don't know how to "unsparse" (remove index gaps) from a field.
So, I need "LIMIT $n,1 MOD $m" or I need "REMOVE ROW-GAPS FROM AUTOINCREMENTED FIELD", so to say.
How could I do this?
Kind regards
Markus