MySQL ORDER by sort problem

Source: Internet
Author: User

Reference Blog http://blog.csdn.net/hollboy/article/details/13296601

The sort of MySQL order by has encountered a problem today

The scenario is that the sorted field is set to a varchar type, and then the sort is not in the order of the largest to the smaller

According to the order in the diagram should be the positive sequence, 9 rows at the top, but actually 666 rows at the top

One way to solve this problem

The actual situation is to start by the leftmost first sort and then in a comparison, here in the SQL when the solution can be added 0, or the front plus--also can OH

The second solution

Change the field type to int type see below

The sorting is correct immediately, and the position is on the right, and may also be sorted by the number on the right, and the time type is no longer described.

MySQL ORDER by sort problem

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.