MSSQL查詢第五條到第十條資料

來源:互聯網
上載者:User


查詢資料庫中第五條資料到第十條資料,分兩種情況:


1,ID是串連的,當然這種情況比較好查。直接SELECT就可以了,取ID大於5小於10就可以了,

這種情況比較少。


2,ID不是串連的,如果要取第五條資料到第十條資料,就得從SQL查詢SELECT著手


select top 10 * from TB1 where Id not in (select top 5 Id from TB1 )



其中10表示:查詢的數量,5表示是從第幾條開始查。

相關文章

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.