1、oracle數據庫:(注:tableName.id指的是tableName的主鍵)
select * from
(select tableName.*,rownum as con from tableName
where rownum <= m
order by tableName.id desc)
where con >= n;
2、SQLServer數據庫:(注:tableName.id指的是tableName的主鍵)
實現原理解釋:
1)先查出前m面條記錄
2)再查出前n面條記錄
3)最后通過條件過濾掉前m條記錄
方法一:
select top n-m+1 * from tableName
where tableName.id not in
(select top m tableName.id from tableName order by desc tableName.id)
order by tableName.id
方法二:
select top n-m+1 * from tableName as a where not exists
(select * from
(select top m * from tableName order by id desc) b
where b.id = a.id)
order by id desc
3、MySQL數據庫:
select * from tableName limit m, n;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。