Sqlite: How to show results X to Y

I am new to sql (and sqlite) and so far I have learned that I need to use count to get the number of rows returned by a query. However if I get for example 10'000 results and would like to divide them into 10 "pages" I would like to show only results 0-1'000 on one page , 1'000-2'000 on another page and so on.

How should I write a sql query that shows only the results I am intrested in? I guess I would have to do something like this:

select *
from sometable
where somecol like '%whatever%'
   AND resultcount > 1000
   AND resultcount < 2000;

I apologize if this has been answered before but I do not know what I should search for and so far I have not found any solutions that are simple enough for a beginner ;)


You could use the LIMIT and OFFSET feature of sqlite.

FROM sometable
WHERE somecol LIKE '%whatever%'
LIMIT 1000 OFFSET 1000

LIMIT X OFFSET Y is a LIMIT of X records, with a Y OFFSET

so LIMIT 10 OFFSET 50 will return 10 records, with a 50 record offset.

There is also LIMIT <skip>, <count> syntax if you prefer that style

Need Your Help

Directive isolated scope initialized from injected service

javascript angularjs

It have to be smth simple, but so far I can't get it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.