From a simple SQL query in MySQL how can I get only the 5 first results?
And then, how can I get the next 5 results?
For example (pseudo code):
select * from (select * from some_table) where <first 5 results>
select * from (select * from some_table) where <second 5 results (6-10)>
You should be able to get the first 5 results with a
LIMIT 5at the end of your statement:And then you can get results 6-10 with a query like this:
As another example, you could get results 6-15 with a query like this:
Please keep in mind that, if you don’t add an
ORDER BYstatement, the results are retrieved in arbitrary order. Consequently, it doesn’t really make sense to useLIMITandOFFSETin the absence of anORDER BY.