MySQL using notes (vii) Sorting and restricting data logging queries

Source: Internet
Author: User
Tags creative commons attribution

by Francis_hao Dec 17,2016

Sort data Record Query

Sorting refers to the orderly emission of filtered data that meets the criteria, in ascending (ASC (default)) and descending (DESC) mode.

mysql> Select Field1 field2 ... from table_name [where condition ] ORDER by FIELDM1 [Asc|desc],fieldm2 asc| Desc,......;

The second sort field here is sorted in the same situation as the first sort field. If the first sort field does not have the same item, the second sort field has no effect.

Restricting Data logging queries

If the query gets too much data, you can limit the number of displays.

mysql> Select Field1 field2 ... from table_name [where condition ] limit [ start position ,] Number of c6> ;

Where the starting position can be omitted, the default is 0, that is, the first data.

Starting with the first data, only two data is displayed.


This article was authored by Liu Yinghao and licensed under the Creative Commons Attribution-NonCommercial use-Share 3.0 Chinese mainland license agreement in the same way. Welcome reprint, please specify the source:
Reprinted from: http://www.cnblogs.com/yinghao1991/p/6193089.html

Reference

[1] Wang Feifei Triyang He Yaju "MySQL database application from getting started to mastering (second edition)" Beijing: China Railway Press, September 2014

MySQL using notes (vii) Sorting and restricting data logging queries

Related Article

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.