读取数据表中第m条到第n条的数据,SQL语句怎么写?

对于MySQL或者Oracle来说,如果实现从Table 表中取出第 m 条到第 n 条的记录操作,我们需要TOP函数(不是所有的数据库都支持TOP函数):Select Top子句

但是,你能想到几种方法?

(1)使用not in 
Select TOP n-m+1 *  
FROM Table  
Where (id NOT IN (Select TOP m-1 id FROM Table ))    

(2)使用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 


原文地址:https://www.cnblogs.com/zifo/p/3568116.html