Used to sort the results of a search in either ascending or descending order:
mysql> select Surname, PIN from Students ORDER BY PIN ; +---------+------+ | Surname | PIN | +---------+------+ | Smith | 0151 | | Rose | 0672 | | Frost | 1065 | | James | 2108 | | Waite | 2643 | | Cross | 7519 | | Jones | 8198 | | Watson | 9437 | +---------+------+ 8 rows in set (0.00 sec) |
Or by descending order, append DESC to the command:
mysql> select Surname, PIN from Students ORDER BY PIN DESC; +---------+------+ | Surname | PIN | +---------+------+ | Watson | 9437 | | Jones | 8198 | | Cross | 7519 | | Waite | 2643 | | James | 2108 | | Frost | 1065 | | Rose | 0672 | | Smith | 0151 | +---------+------+ 8 rows in set (0.00 sec) |