天天看點

讀取資料表中第m條到第n條的資料,SQL語句怎麼寫?

但是,你能想到幾種方法?

(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