從Table 表中取出第 m 條到第 n 條的記錄

2021-04-14 02:41:00 字數 841 閱讀 7862

從table 表中取出第 m 條到第 n 條的記錄:(not in 版本)

select

topn-m

+1*from

table

where

(id 

notin

(select

topm-1

id from

table

))  

--從table表中取出第m到n條記錄 (exists版本)

select

topn-m

+1*from

table

asa 

where

notexists

(select

*from

(select

topm-1

*from

table

order

byid) b 

where

b.id

=a.id ) 

order

byid

--m為上標,n為下標,例如取出第8到12條記錄,m=8,n=12,table為表名

select

topn-m

+1*from

table

where

id>

(select

max(id) 

from

(select

topm-1

id from

table

order

byid 

asc) 

temp

) order

byid 

asc

從Table 表中取出第 m 條到第 n 條的記錄

從table 表中取出第 m 條到第 n 條的記錄 從table 表中取出第 m 條到第 n 條的記錄 not in 版本 select top n m 1 from table where id not in select top m 1 id from table 從table表中取出第m到n條...

SQL Oracle取出第m條到第n條記錄的方法

sql oracle取出第m條到第n條記錄的方法 用一句sql取出第 m 條到第 n 條記錄的方法 從table 表中取出第 m 條到第 n 條的記錄 not in 版本 select top n m 1 from table where id not in select top m 1 id fr...

SQL取出第 m 條到第 n 條記錄的方法

從table 表中取出第 m 條到第 n 條的記錄 not in 版本 select top n m 1 from table where id not in select top m 1 id from table 從table表中取出第m到n條記錄 exists版本 select top n m...