
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we sort MySQL output in descending order?
We need to specify DESC (short form for DESCENDING) keyword in ORDER BY clause if we want to sort out the result set in descending order.
Syntax
Select column1, column2,…,columN From table_name ORDER BY column1[column2,…] DESC;
Example
In the following example, we have sorted the result set by column ‘Id’ in the descending order.
mysql> Select * from Student ORDER BY Id DESC; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 17 | Raman | Shimla | Computers | | 15 | Harshit | Delhi | Commerce | | 2 | Aarav | Mumbai | History | | 1 | Gaurav | Delhi | Computers | +------+---------+---------+-----------+ 4 rows in set (0.00 sec)
- Related Articles
- How can we sort MySQL output in ascending order?
- Sort by date & time in descending order in MySQL?
- How to perform descending order sort in MongoDB?
- Sort MongoDB documents in descending order
- How to sort TreeSet in descending order in Java?
- Sort a column in descending order after placing argument in MySQL IN()?
- How to sort an ArrayList in Descending Order in Java
- How to sort an ArrayList in Java in descending order?
- Sort list elements in descending order in C#
- How can we get the sorted MySQL output?
- Sort an array in descending order using C#
- How to sort List in descending order using Comparator in Java
- How do you sort an array in C# in descending order?
- C# program to sort an array in descending order
- 8085 Program to perform selection sort in descending order

Advertisements