//可以运行select rownum from emp where rownum<6;//不可以运行select rownum from emp where rownum>6;//不可以运行,无结果select rownum from emp where rownum<6and rownum>3;//例题 假设每页显示3条,查询出第二页
查不出
select*from(select emp.*,rownum from emp) ee where ee.rownum>3and ee.rownum<7;
可以查出(要给伪列rownum设置别名)
select*from(select emp.*,rownum rn from emp) ee where ee.rn>3and ee.rn<7;
或
select*from(select emp.*,rownum rn from emp)where rn>3and rn<7;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
mysql实现分页查询
#查询前五条学生信息SELECT*FROM students LIMIT0,5;#如果你要查询的数据,是从第一条数据开始的,那么0可以省略,如下:SELECT*FROM employees LIMIT5;#案例2:查询第11条到第25条(起始索引从10开始,显示15条)SELECT*FROM students LIMIT10,15;