Get Sorted Output Based on Multiple Columns



We can specify multiple columns in ORDER BY clause to get the sorted output based on those multiple columns. Following as an example to make this concept clearer −

mysql> Select * from Student ORDER BY Name, Address;

+------+---------+---------+-----------+
| 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.12 sec)
Updated on: 2020-06-20T06:25:11+05:30

188 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements