Home > Database > Mysql Tutorial > SQL Server中选出指定范围行的SQL语句代码

SQL Server中选出指定范围行的SQL语句代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:57:29
Original
1180 people have browsed it

SQL Server中选出指定范围行的SQL语句代码写法实例

在数据库查询的时候,我们有时有这样的需求,就是要找出数据表里指定范围行内的数据记录,比如说要找出数据表里第10行到第20行的这10条数据,那么我们怎么来实现呢?

按照通常的方法是实现不了的,我们得借助于临时表以及一个函数来实现


代码如下:


Select no=Identity(int,1,1),* Into #temptable From dbo.teacher_info order by teacher_name--利用Identity函数生成记录序号


Select * From #temptable Where no>=10 And no

Drop Table #temptable--用完后删除临时表


这样我们就实现了我们的目的。
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template