Home > Database > Mysql Tutorial > body text

MySQL查询第几行到第几行记录

WBOY
Release: 2016-06-07 17:06:52
Original
1451 people have browsed it

1、查询第一行记录: select * from table limit 1 2、查询第n行到第m行记录 select * from table1 limit n-

1、查询第一行记录:

    select   *   from   table  limit   1

2、查询第n行到第m行记录
     select * from table1  limit n-1,m-n;

     SELECT * FROM table LIMIT 5,10;返回第6行到第15行的记录

     select * from employee limit 3,1; // 返回第4行

3、查询前n行记录

    select * from table1 limit 0,n;

    select * from table1 limit n;

4、查询后n行记录

     select * from table1 order by id desc dlimit n;//倒序排序,,取前n行 id为自增形式

5、查询一条记录($id)的下一条记录

     select * from table1 where id>$id  order by id asc dlimit 1

6、查询一条记录($id)的上一条记录

    select * from table1 where id

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template