sql 查询 第 n 条到第 m 条的记录

时间:2022-11-10 04:46:32

SELECT TOP 100 *
FROM 表名
WHERE (主键(或标识列)NOT IN
(SELECT TOP 100 主键(或标识列)
FROM 表名))
===================================================
从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 *
FROM publish
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM publish))

id 为publish 表的关键字

=================================================

写成一行

从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 * FROM publish WHERE (id NOT IN (SELECT TOP n-1 id FROM publish))