如果要按降序对结果集进行排序,则需要在ORDER BY子句中指定DESC(DESCENDING的缩写)关键字。
Select column1, column2,…,columN From table_name ORDER BY column1[column2,…] DESC;
在下面的示例中,我们已按“ Id”列的降序对结果集进行了排序。
mysql> Select * from Student ORDER BY Id DESC; +------+---------+---------+-----------+ | Id | Name | Address | Subject | +------+---------+---------+-----------+ | 17 | Raman | Shimla | Computers | | 15 | Harshit | Delhi | Commerce | | 2 | Aarav | Mumbai | History | | 1 | Gaurav | Delhi | Computers | +------+---------+---------+-----------+ 4 rows in set (0.00 sec)