Select From Table in Descending Order
When you select rows from a table, you can select those based on the ascending and descending order of the values in a column.
In this MySQL Tutorial, we shall learn how to select rows of a table based on the descending order of values in a column.
Syntax – Get Rows in Descending Order
To sort rows of a result set in descending order of values in a column, use the syntax of the following SQL Query.
</>
Copy
SELECT * FROM table_name ORDER BY column_name DESC;
The character set of the column is considered while sorting the column values in descending order.
Example 1 – Sort Rows of Table in Descending Order
Consider the following students
table.
Now we shall sort these rows in DESCENDING ORDER of name
column.
Run the following query to sort the records in descending order.
</>
Copy
SELECT * FROM students ORDER BY name DESC;