mysql queries the statements recorded from line 1 to line 1

  • 2020-05-10 23:03:41
  • OfStack

1. Query the record in line 1:
select * from table limit 1
2. Query the records of rows n to m
select * from table1 limit n-1,m-n;
SELECT * FROM table LIMIT 5,10; Returns a record of lines 6 through 15
select * from employee limit 3,1; // returns line 4
3. Query the previous n row record
select * from table1 limit 0,n;
or
select * from table1 limit n;
4. Record n row after query
select * from table1 order by id desc dlimit n; // reverse sort, take the former n line id as the self-increasing form
5. Query the next record of one record ($id)
select * from table1 where id > $id order by id asc dlimit 1
6. Query the previous record of one record ($id)
select * from table1 where id < $id order by id desc dlimit 1

Related articles: