SQL server implements the basic paging function, and SQL SERVER implements Paging

Source: Internet
Author: User

SQL server implements the basic paging function, and SQL SERVER implements Paging
SQL SERVER implements basic paging functions using NOT IN and SELECT TOP for paging

Use WH_WorkshopInforSys -- create a temporary table select IDENTITY (int, 1, 1) as id, * into mytablefrom dbo. pnlBaobiao -- select top 10 * from mytablewhere id not in (select top 40 id from mytable order by id) order by id -- delete table drop table mytable


Since the original table does not have a sequence number for the table, we need to create a temporary table to store the table with the auto-increment sequence number, and then perform paging operations on the table, the temporary table can be deleted at the end, so the efficiency may be relatively low. This is the clearest way of thinking, and the query speed is acceptable for tables with IDs.
, Table starting from 41
How to achieve efficient jsp paging display (the database is sqlserver), it is best to have an instance;

Use SQL paging.
Select top 10 from tablename where id not in (select top 10 id from tablename)

Generally, all data in the database is retrieved at one time on the page.
Mssql can use the top keyword to query only the displayed content.

Paging statement using sqlserver

Here is a reference
String SQL = "select top 5 * from bean where id not in (select top" + 5 * (pageNum-1) + "id from bean order by id )";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.