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

How to use limit in Mysql

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how to use limit in Mysql. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

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. 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 line is 0 (not 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.

Notice the difference between limit 10 and limit 9.

The above is how to use limit in Mysql. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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