SELECT TOP [pageSize] * FROM (SELECT TOP [pageSize*currentPage + 1] * FROM news WHERE constraint='constraint' ORDER BY id DESC ) ORDER BY id ASC
其中紅色的地方 pageSize 是一頁顯示的筆數、currentPage 是現在要顯示的是第幾頁(假設起始序號是 0)。
Software entities (class, modules, functions, etc.) should be open for extension, but closed for modification. Junior programmers create simple solutions to simple problems. Senior programmers create complex solutions to complex problems. Great programmers find simple solutions to complex problems. 註1:本部落格的範例程式碼在 2015 年以前的文章中,大多是以全型空白做縮排。如需服用,請自行用文字編輯器的取代功能把全型空白取代成半型空白。
- Bertrand Meyer
- Charles Connell
註2:本部落格的內容授權請參閱部落格底部的授權宣告。
SELECT TOP [pageSize] * FROM (SELECT TOP [pageSize*currentPage + 1] * FROM news WHERE constraint='constraint' ORDER BY id DESC ) ORDER BY id ASC
其中紅色的地方 pageSize 是一頁顯示的筆數、currentPage 是現在要顯示的是第幾頁(假設起始序號是 0)。