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

2022-03-20 04:08:16 字數 594 閱讀 4676

從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條記錄 (exists版本)

select top n-m+1 * from table as a where not exists

(select * from (select top m-1 * from table order by id) b where b.id=a.id ) 

order by id

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

select top n-m+1 * from table 

where id>(select max(id) from 

(select top m-1 id from table order by id asc) temp) 

order by id asc 

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

從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 f...

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...