Mysqlin is sorted by query id _ MySQL

Source: Internet
Author: User
Mysqlin sorts bitsCN.com by query id


Mysql in is sorted by query id

When mysql in is queried, the returned results are sorted by themselves. if you want to sort the results by the ID of our query,
Order by field is used. the following example shows how to sort mysql in queries.

Example: www.bitsCN.com

SQL: select * from table where id IN (3, 6, 9, 1, 2, 5, 8, 7 );

After such a situation is obtained, the IDS are sorted by 1, 2, 3, 4, 5, 6, 7, 8, 9, but if we really want
What should I do with the order of the above? We can use order by field

SQL: select * from table where id IN (,) order by field (id );

The query result is sorted by the custom ID.

BitsCN.com

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.