Home  >  Article  >  Database  >  How can we get sorted output based on multiple columns?

How can we get sorted output based on multiple columns?

PHPz
PHPzforward
2023-09-06 11:49:02822browse

How can we get sorted output based on multiple columns?

We can specify multiple columns in the ORDER BY clause to get sorted output based on these multiple columns. The following is 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)

The above is the detailed content of How can we get sorted output based on multiple columns?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete