
- 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 ascending order?
We need to specify ASC (short form for ASCENDING) keyword in ORDER BY clause if we want to sort out the result set in ascending order.
Syntax
Select column1, column2,…,columN From table_name ORDER BY column1[column2,…] ASC;
Example
In the following example, we have sorted the result set by column ‘Name’ in the ascending order.
mysql> Select * from Student ORDER BY Name ASC; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 2 | Aarav | Mumbai | History | | 1 | Gaurav | Delhi | Computers | | 15 | Harshit | Delhi | Commerce | | 17 | Raman | Shimla | Computers | +------+---------+---------+-----------+ 4 rows in set (0.00 sec)
- Related Articles
- How can we sort MySQL output in descending order?
- How to perform ascending order sort in MongoDB?
- How to sort Java array elements in ascending order?
- How can we get the sorted MySQL output?
- Sort index in ascending order – Python Pandas
- How to sort an ArrayList in Java in ascending order?
- How to sort an ArrayList in Ascending Order in Java
- How do you sort an array in C# in ascending order?
- 8085 Program to perform bubble sort in ascending order
- 8085 Program to perform selection sort in ascending order
- Sort the MongoDB documents in ascending order with aggregation?
- How to sort bars in a bar plot in ascending order (Matplotlib)?
- Golang Program To Sort An Array In Ascending Order Using Insertion Sort
- Swift Program to sort an array in ascending order using bubble sort
- Swift Program to sort an array in ascending order using selection sort

Advertisements