Sql server:
//鍓?琛?/p>
select top 5 * from table
//鏌ヨ絎琺鏉″埌絎琻鏉¤褰?
Select top (n-(m-1)) * from [tablename] where [parimary key] not in(select top (m-1) [parimary key] from [tablename] order by [鎺掑簭瀛楁鍙婃帓搴忔柟娉昡) order by [鎺掑簭瀛楁鍙婃帓搴忔柟娉昡;
oracle:
//鍓?琛?/p>
select * from table where rownum <= 5;
//絎?鍒?0琛?/p>
select * from table where rownum<10
minus
select * from table where rownum<4;
綾諱技鍙互瀹炵幇鍒嗛〉鍔熻兘
MySQL
瀹炵幇Top N鍙奙鑷砃孌電殑璁板綍鏌ヨ
鎴戜滑鍙互鍒╃敤MySQL涓璖ELECT鏀寔鐨勪竴涓瓙鍙モ斺擫IMIT鈥斺旀潵瀹屾垚榪欓」鍔熻兘銆?/p>
LIMIT鍙互瀹炵幇top N鏌ヨ錛屼篃鍙互瀹炵幇M鑷砃錛堟煇涓孌碉級鐨勮褰曟煡璇紝鍏蜂綋璇硶濡備笅錛?/p>
SELECT * FROM MYTABLE
ORDER BY AFIELD
LIMIT offset, recnum
鍏朵腑offset涓轟粠絎嚑鏉★紙M+1錛夎褰曞紑濮嬶紝recnum涓鴻繑鍥炵殑璁板綍鏉℃暟銆備緥錛?/p>
select * from mytable
order by afield
limit 2, 5
鍗蟲剰涓轟粠絎?鏉¤褰曞紑濮嬬殑5鏉¤褰曘?/p>