为了以有意义的方式对行进行排序,我们可以使用ORDER BY子句。假设我们想对以下表的行进行排序 −
mysql> Select * from Student; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Gaurav | 100 | B.tech | | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
下面的查询按照 ‘Name’ 对表进行排序。
mysql> Select * from student order by name; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | | Gaurav | 100 | B.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
下面的查询按'Grade'对表进行了排序。
mysql> Select * from student order by Grade; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Gaurav | 100 | B.tech | | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
以上是如何以有意义的方式对行进行排序?的详细内容。更多信息请关注PHP中文网其他相关文章!