資料庫分頁關鍵字

2021-08-30 06:53:56 字數 861 閱讀 2949

mysql分頁採用limt關鍵字

select * from t_order limit 5,10; #返回第6-15行資料

select * from  t_order limit  5; #返回前5行

select * from  t_order limit  0,5; #返回前5行

mssql 2000分頁採用top關鍵字(20005以上版本也支援關鍵字rownum)

select top 10 * from t_order where id not in (select id from t_order where id>5 ); //返回第6到15行資料

其中10表示取10記錄 5表示從第5條記錄開始取

oracle分頁

①採用rownum關鍵字(三層巢狀)

select * from(

select a.*,rownum  num from

(select * from t_order)a

where

rownum<=15)

where num>=5;--返回第5-15行資料

②採用row_number解析函式進行分頁(效率更高)

select xx.* from(

select t.*,row_number() over(order by o_id)as num

from t_order t

)xxwhere num between 5 and 15;

--返回第5-15行資料

解析函式能用格式

函式() over(pertion by 字段 order by 字段);

pertion 按照某個字段分割槽

order 按照勒個字段排序

資料庫關鍵字Union和Union All的區別

sql 的union操作符合併兩個或者多個select語句的結果.請注意 union內部的每個select語句必須擁有相同數量的列,且列必須有相似的資料型別,同時select語句中列的順序必須相同.建表語句 建表語句 create table table2 id int 2 auto increme...

資料庫筆記 MySQL 關鍵字 函式

以下為本次應用的三張表,其結構和內容如下 表1 t score 分數表 create table t score stu id int lesson id varchar 255 score int 表2 t stu profile 學生表 create table t stu profile st...

Access資料庫操作注意關鍵字

最近乙個專案中用到在access資料庫中修改使用者的密碼,由於對於這種檔案型資料庫用得比較少,在謝這個語句的時候開始是這樣寫的 update reportuser set password newpassword where memberid username 編譯可以通過,但是每次執行到這個地方的...