Today suddenly turned to SQL for the client to write paging data, found that the logic is not correct. Descending by ID
It was written in this way:
#翻上一页: Select field from table where Id>lastid ORDER by id DESC limit pagesize# turn next page: Select field from table where Id<lastid order b Y ID desc Limit pageSize
LastID is the near ID, that is, the previous page is the topmost ID, the next page is the bottom ID
PageSize is the number of page bars
Clearly, there is a problem with logic.
If the Pagesize=3;id list is like this:
Ten 9 8 7 6 5 4 3 2 1
Because the ID is descending, the page turn is like this:
1 First page:2 second page: 93 third page: 8 7
...
But actually, the backend receives three parameters: Lastid,pagesize,direct. Direct=0 represents the previous page, 1 next page.
Lastid=9, and down a page, then id<9 Descending, get 8 7 6, no problem;
The previous page, then id>9, if only descending: 14 13 12, obviously should be ascending, that is: 10 11 12, and then descending, return to the client: 12 11 10
So
It should be written .:
1 #翻上一页:2 Select * from 3(SelectField fromTablewhereId>LastIDOrder byID limit pageSize)Temp4 Order byIddesc5 #翻下一页:6 SelectField fromTablewhereId<LastIDOrder byIddescLimit PageSize
About Client interface Paging SQL statements