Marius Prollak
Marius Prollak

Reputation: 368

Mysql select 3 entries, skip next two, select next 3 etc

I'm trying to select from mysql like this: select 3 entries, skip the next 2 and so on. Is this possible with mod,id ? Or what would be the best possible way to do it ?

(I don't delete any entries ever, so the order won't be a concern)

//Edit: Thinking of something like select * from table where id mod 4 <> 0 which would skip the 4th, any way to also make it skip the 5th ?

Upvotes: 1

Views: 80

Answers (2)

Strawberry
Strawberry

Reputation: 33945

SELECT ...
  FROM ... 
 WHERE MOD(...,5) NOT IN (4,0);

?

Upvotes: 1

Anatoliy  Gusarov
Anatoliy Gusarov

Reputation: 808

I suggest you to add one more column, and update it on insert (1,2,3...), and then use WHERE clause.

Make things more simple.

And don't forget to add index on this column

Upvotes: 3

Related Questions