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

How can we get sorted output based on multiple columns?

PHPz
Release: 2023-09-06 11:49:02
forward
875 people have browsed it

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template