Getting specific rows from recordset
I have a big database result set and I want get specific rows from them with 1 Query:
1., 60.
and 61.,120.
and 121.,180.
... and every 60th and 61st record until I have all, the complete result n开发者_开发问答eeds to be provided by 1 Query.
Any idea how I can do that?
The LIMIT/OFFSET is not what I'm looking for, as I would need to repeat it many times.
I found an article that uses a single select statement to do this. The statement itself is more complex, but certainly not cryptic by any means.
SELECT *
FROM (
SELECT
@row := @row +1 AS rownum, noun
FROM (
SELECT @row :=0) r, nouns
) ranked
WHERE rownum %4 =1
Here is the article.
How about
WHERE id % 60 IN ('0','1')
*untested!
精彩评论