Home >Database >Mysql Tutorial >How to set descending order in mysql query
In mysql, you can use the desc keyword to display the query results in descending order. This keyword is the abbreviation of descend. It is often used in conjunction with the order by clause to make the query results in descending order. The syntax is "select field 1, field 2... from table name order by specified field desc".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
Use the desc keyword
What does desc mean?
desc is the abbreviation of [describe v. describe] and [descend v. drop].
desc and asc in mysql:
select 字段1,字段2... from 表名 order by 指定字段 desc;2. Use asc to display the query results in ascending order. It also needs to be combined with the order by clause: # SQL result ascending statement format:
select 字段1,字段2... from 表名 order by 指定字段 asc;3. If you need two To display the fields in ascending and descending order, the following sql statement format is required:
select 字段1,字段2... from 表名 order by 指定字段1 asc, 指定字段2 desc;If there are any deficiencies in the content, please give me some advice... Recommended learning:
The above is the detailed content of How to set descending order in mysql query. For more information, please follow other related articles on the PHP Chinese website!