
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Advertisements