Select*fromStudentORDERBYNameASC;+------+---------+---------"/> Select*fromStudentORDERBYNameASC;+------+---------+---------">

Home  >  Article  >  Database  >  How can we sort MySQL output in ascending order?

How can we sort MySQL output in ascending order?

王林
王林forward
2023-08-30 21:09:071287browse

我们如何对 MySQL 输出进行升序排序?

#If we want to sort the result set in ascending order, we need to specify the ASC (abbreviation for ASCENDING) keyword in the ORDER BY clause.

Syntax

Select column1, column2,…,columN From table_name ORDER BY column1[column2,…] ASC;

Example

In the following example, we sort the result set in ascending order by the "Name" column.

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)

The above is the detailed content of How can we sort MySQL output in ascending order?. 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