要怎样以升序对 MySQL 输出进行排序?
如果要对结果集进行升序排序,我们在 ORDER BY 子句中需要指定 ASC(ASCENDING 的简写)关键字。
语法
Select column1, column2,…,columN From table_name ORDER BY column1[column2,…] ASC;
示例
在下面的示例中,我们按升序对 ‘Name’ 列中的结果集进行了排序。
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)
广告