(based in PostgreSQL)
Limit:if a limit count is given, no more than taht many rows being returned (but possibly less, if query itself yields less Rows
Offset: offset says to skip this many rows before beginning to return rows to the client. Offset 0 is the same as omitting the offsetclause. If both offset and LIMIT appear, then OFFSET rows is skipped before starting to count the limit rows that is returned.
SELECT select_list From Table_expression | All}] [OFFSET number]
Fetch:retrieve rows from a query using a cursor
FETCH [Direction {from | in}]CursornamewhereDirection can be emptyorOne of: NEXTPRIOR First Last ABSOLUTECountRELATIVECount Count AllFORWARD FORWARDCountFORWARD AllBackward BackwardCountBackward All
About Direction Parameters Information in:http://www.postgresql.org/docs/8.1/static/sql-fetch.html
Pagination:
Pagination_limit = 20
offset = get_http_argument ('Offset', optional=true)or1Offset=int (offset) offset= OffsetifOffset > 0Else1Limit=pagination_limit Offset= (offset-1) *Limit Result= db (). List (" "SELECT *, COUNT (*) over () as Total_rows
From TestOFFSET%(offset) s FETCH first% (limit) ROWS only" ", Offset=offset, Limit=limit)
Total_pages = Total_rows/limit
You can get different results by request a different page:
{% if total_pages > 1}<Divclass= "pagination pagination-centered mt-10"> <ulclass= "Clearfix inline-block">{% if offset > 6}<Li><ahref= "javascript:void (0)">1</a></Li> <Li><aclass= "Disabled"href= "javascript:void (0);">...</a></Li>{% endif%} {% for I in range (offset-5, offset)%} {% If i > 0}<Liclass= "Inline-block"><ahref= "javascript:void (0);">{{i}}</a></Li>{% endif%} {% endfor%}<Liclass= "Current Inline-block"><aclass= "Current"href= "javascript:void (0);">{{offset}}</a></Li>{% for I in range (5)%} {% if offset + loop.index<= Total_pages%} <li class= "Inline-block"><ahref= "javascript:void (0);">{{offset + loop.index}}</a></Li>{% endif%} {% endfor%} {% if total_pages > offset + 5} <Li><aclass= "Disabled"href= "javascript:void (0)">...</a></Li> <Li> <ahref= "javascript:void (0)">{{Total_pages |int}}</a> </Li>{% endif%}</ul> </Div>{% endif%}
Pagination-limit & Offset (python)