Code example of the Order By multi-field sorting rule in MySQL, mysqlorder
Mentioned above
A whimsy, want to know what rules mysql order by sorting is based on? Okay. If you don't have much to say, go to the topic.
MySql order by single Field
Create
PrefaceIn addition to the regular join statements, there is a class of query statements that are also used more frequently, that is, orderby,group by and distinct. Considering that all three types of queries involve the sorting of data, I put them
In the reconstruction of the site, the data structure is usually modified, so add, delete, add the MySQL table field is unavoidable, and sometimes for convenience, but also increase the modification of the table or field comments, the same field
Mysql queries are sorted by the specified order of a field, and mysql fields are sorted by the specified order.
When using Sphinx in the project, many people encounter the following problem: After using mysql + Sphinx to retrieve the relevant ID,
In the reconstruction of the site, the data structure is usually modified, so add, delete, add the MySQL table field is unavoidable, and sometimes for convenience, but also increase the modification of the table or field comments, the same field
In some cases, MySQL can use an index to satisfy the order by clause without additional sorting. The where condition and order by condition use the same index, and the order by order is the same as the index order, and the order by field is both
The MySQL order BY keyword is used to classify the data in the record.
MySQL ORDER BY keyword classified by keyword
The ORDER BY keyword is used to classify the data in a record.
MySQL ORDER BY syntax
The code is as follows
Copy
Mysql records are output in reverse order based on the date field, and mysql Date Field in reverse order
We know that inverted output is very simple.
Select * from table order by id desc
You can simply
Now the question is how to output the Date
1. Display the list of databasesshow databases; # View all current databasesShow Databases \g #以行的方式显示2. On the command line, execute the SQL statementMysql-e ' show databases '-uroot-p123456mysqlshow-uroot-p123456 # not used, just remember the one
MySQL Order By Principle and Optimization
1 IntroductionFor business (MySQL) DBAs or business developers, order by is a common business function that sorts the results based on specified fields to meet front-end display requirements. However,
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.