Everything is because of the paging - talk again

xiaoxiao2021-03-06  66

I haven't been confused by paging for a long time, because the amount of data in the table has always been small, so I use the record set of PageSize and AbsolutePage. This drawback is to read the records used in one time, and the number of records is very slow.

The idea is to find a way, just read the required record ~ ​​huh ~

More common is the use of in operators, such as

SELECT TOP

Pagesize * from a where id not in (SELECT TOP

PageSize * Pageno ID from a where)

Pay attention to the part of the red, the SELECT statement is their value

Similarly, the data is not a lot, but it is too much, because IN is not efficient.

I want to go, find a method, using the ID (俺 always set it into a self-increasing),

The ID is from a small to a large row, in fact, as long as the current page minimum ID should be greater than how much, then use the top operator.

Look at

SELECT TOP

PageSize * from a where id>

MinID

The minid of the first page is of course 0, and then you can get the first page maximum ID value, it is the value of the ID must be greater than the value in the second page, the class push ~

Of course, there is a problem, if you want to jump directly to the specified page ~~ that is not good :(

Jump to the last page is still very simple, just use the Order By ID DESC

This thought is still a flaw. If you don't sort by ID, it will be very troublesome. The solution you can think of is that the above is the sub-query, and then set a layer of query ~

If you don't understand, sorry, that only shows that the expression of 俺 is abused ~

Ha ha ~ so don't worry!

)

,

)

转载请注明原文地址:https://www.9cbs.com/read-89867.html

New Post(0)