如何在SQL Server中实现 Limit m,n 的功能
2022-11-12 09:30:49
内容摘要
这篇文章主要为大家详细介绍了如何在SQL Server中实现 Limit m,n 的功能,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!在MySQL中,可以用
文章正文
这篇文章主要为大家详细介绍了如何在SQL Server中实现 Limit m,n 的功能,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
在MySQL中,可以用 Limit 来查询第 m 列到第 n 列的记录,例如:代码如下:
1 2 | <code>select * from tablename limit m, n </code> |
代码如下:
1 2 | <code>select id from tablename </code> |
代码如下:
1 2 | <code>select top 6 id from tablename </code> |
代码如下:
1 2 3 4 5 | <code>select top 3 id from tablename where id not in ( select top 6 id from tablename ) </code> |
代码如下:
1 2 3 4 5 | <code>select top (n-m+1) id from tablename where id not in ( select top m-1 id from tablename ) </code> |
代码如下:
1 2 3 4 5 | <code>select top @pageSize id from tablename where id not in ( select top @offset id from tablename ) </code> |
注:关于如何在SQL Server中实现 Limit m,n 的功能的内容就先介绍到这里,更多相关文章的可以留意
代码注释