How to query intermediate records in MySQL

Source: Internet
Author: User

The method for querying intermediate records in MySQL is not complex. The following describes how to query intermediate records in MySQL. If you have encountered any problem with querying intermediate records in MySQL, take a look.

Query the first five records in the table:

 
 
  1. Select * from table 1 limit 5;
  2.  
  3. Select * from table 1 limit 0, 5;
  4.  


Query 5th to 7th records in a table:

 
 
  1. Select * from table 1 limit 4, 3;
  2.  

Select a record:

 
 
  1. Select * from table 1 order by rand () limit 1;
  2.  

Select n records:

 
 
  1. Select * from table 1 order by rand () limit n;
  2.  

Transformed from the MySQL Query Class of discuz

How MySQL query optimizer works

Non-empty question in MySQL Query

MySQL query results are sorted by a certain value

Use functions to query row numbers in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.