MySQL Order by multiple fields

Source: Internet
Author: User

Is the result of adding only one sort:

As you can see, a single field is no problem. What if I join C2? It's c2.

It can be found that the order here is first ordered by C1, and then for the C1 after the same sequence of the same elements, and according to C2 do a descending sort. The following are the C1,C2, the results are consistent.

As a summary, each field is separated by a comma when multiple fields are ordered, and is added by default if the field does not indicate the sort method. The sort is sorted first by first field, if you have the same followed by subsequent fields.

MySQL Order by multiple fields

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.