Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

On the use of query limit in MySQL Database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor to share with you is about the use of MySQL database query limit, many people do not understand, today, in order to let you know more about the use of MySQL database query limit, so give you a summary of the following content, let's look down. I'm sure you'll get something.

In my opinion, limit is probably the most frequently used method in mysql, so let's explain what limit does and how to use it correctly.

SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset

The LIMIT clause can be used to force the SELECT statement to return a specified number of records. LIMIT accepts one or two numeric parameters. Parameter must be an integer constant. If given

Two parameters, the first parameter specifies the offset of the first returned record row, and the second parameter specifies the maximum number of record rows returned. The offset of the initial record row is 0 instead of

1): for compatibility with PostgreSQL, MySQL also supports syntax: LIMIT # OFFSET #.

Mysql > SELECT * FROM table LIMIT 510; / / retrieve record lines 6-15

/ / to retrieve all record rows from a certain offset to the end of the recordset, you can specify the second parameter as-1:

Mysql > SELECT * FROM table LIMIT 95 96-last; / / search the record line.

/ / if only one parameter is given, it represents the maximum number of record rows returned:

Mysql > SELECT * FROM table LIMIT 5; / / retrieve the first five record rows

/ / in other words, LIMIT n is equivalent to LIMIT 0penny n.

These are the details about the use of MySQL database query limit. Do you have anything to gain after reading it? If you want to know more, welcome to the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report