1. Use order by to sort the results of the query, ASC ascending, desc descending:
You can also specify more than one field name and sort order after the order by:
2. Limit the number of query results by using limit:
0, which represents the starting position of the query, can also be understood as the number of skipped, and 2 in the number of queries that need to be queried. There are 3 data in this table because the number of bars is limited to 2, so the actual result is only two. In addition, the initial position here is 0, actually can not write, the default is 0:
There is also a case where the number of specified query results may be greater than the actual number in the table, this time the return result will return all eligible data in the table, for example, there are 3 data in my table, if the specified number is 4, actually query out of 3:
The Where condition, order by sort, and limit can be used together, and many of the actual scenarios are used together:
MySQL Common basic operational Syntax (vi)--conditional query on data ordering and limiting the number of results "command line mode"