如何用sql返回第三条或者第三条记录开始返回?
从数据库中的表中从第三条记录开始取,那么select该怎么写呢?
答:
select * from table_name where id_field not in (select top 3 id_field from table_name)
注意,其实就是把 select top 语句写两遍,第二遍包含了第一遍,然后把是第一遍中的记录用not in剔除就可以了,所以两个where都必须包含相同的外加条件。
//标准最后一页
const string sql_foot = @" SELECT *
FROM TopicDB
WHERE ID not in (
select TOP rowsCount ID
FROM TopicDB
where ForumID=@ForumID
ORDER BY ID ASC) and ForumID=@ForumID order by ID ASC;";