In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to set the display number of mysql query. I hope you will gain a lot after reading this article. Let's discuss it together.
The mysql query sets the method for displaying the number of entries: use the LIMT clause to force the SELECT statement to return the specified number of records, the syntax "SELECT * FROM table name LIMIT [position offset,] rows"; the LIMT parameter must be an integer constant, where the "position offset" specifies which line to start displaying.
When using MySQL SELECT statements, we often return all matching rows, and sometimes we only need to return the first row or the first few rows, so we need to use the MySQL LIMT clause.
The basic syntax format is as follows:
[,]
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 first parameter, "position offset", indicates the row from which the MySQL is displayed, which is an optional parameter, and if you do not specify "position offset", it will start from the first record in the table (the position offset of the first record is 0, the position offset of the second record is 1, and so on); the second parameter "number of rows" indicates the number of records returned.
[example 1] displays the first four rows of the query result of the tb_students_info table. The entered SQL statement and execution result are shown below.
If "location offset" is not specified in the above query conditions, the query starts from the first record by default, and the result shows 4 query records.
If you specify the start position of the returned record, the return result is the specified number of rows starting from the position offset parameter, and the number of rows parameter specifies the number of records returned.
[example 2] in the tb_students_info table, use the LIMIT clause to return a record with 5 rows starting from the fourth record. The SQL statement entered and the execution result are shown below.
As you can see from the results, the statement instructs MySQL to return five records after row 4, with the first number "3" starting at line 4 (the position offset starts at 0, and the position offset for line 4 is 3), and the second number 5 represents the number of rows returned.
So, LIMIT with one parameter specifies that it starts at the first row of the query result, and the only parameter represents the number of rows returned, that is, "LIMIT n" is equivalent to "LIMIT 0line n". LIMIT with two parameters returns data for the specified number of rows starting at any location.
When the first row is returned, the position offset is 0. Therefore, "LIMIT 1, 1" returns line 2 instead of line 1.
Note: "LIMIT 4 OFFSET 3" can be used in MySQL 5.7.This means to get the next three records starting from Article 5, which is the same as the result returned by "LIMIT 4 OFFSET 3".
After reading this article, I believe you have a certain understanding of mysql query how to set the display number, want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.