sql server分頁查詢語句

2021-09-20 03:42:32 字數 447 閱讀 9857

sqlserver分頁查詢

查詢10條第一頁資料 10代表一頁多少條 頁數為10*(1-1)

select top 10 *

from [dbo].[userinfo]

where [ui_fvaruserid] not in

(select top 0 [ui_fvaruserid] from [dbo].[userinfo] order by [ui_fvaruserid]

)order by [ui_fvaruserid]

# 代表會自動轉換字串形式 所以會失敗

應使用${} 這條語句才能執行成功**

#{}會自動轉換成字串形式 好處是最大防止sql注入

${}直接生成在sql語句中 不防止sql注入

所以在後台中能使用#{}就使用#{}

SQL Server 分頁查詢語句

create database xuhanglove gouse xuhanglove gocreate table product pid int primary key identity 1,1 pname varchar 255 not null unique,price float pdat...

sqlserver分頁查詢語句效能分析

目的 通過三種不同的分頁查詢語句的寫法來比較其效能。環境 windows server 2003 sp2 sqlserver2008。資料準備 100萬條資料。說明 下列sql語句中 pagesize表明每頁記錄條數 pageindex表示頁碼 table表示表明,id表示table表中的主鍵。方法...

Sql Server分頁語句

分頁方案一 利用not in和select top分頁 語句形式 select top 10 from testtable where id not in select top 20 id from testtable order by id order by id select top 頁大小 f...