In this tutorial you will learn about the MySQL Sorting Results and its application with practical example.
The result set returned by the SELECT Query is free from any sort order unless you specify it in the SELECT statement.ORDER BY clause is used to sort the result set by a specified column or columns.The ORDER BY clause sorts the records in ascending order by default. To sort the result set in a descending order, use the DESC keyword.
SELECT <field1, field2,...>
ORDER BY <field1, field2,...> ASC|DESC
- We can sort returned result set on any column provided.
- We can sort the result set on column or columns.
- ASC or DESC keyword is used to get result in ascending or descending order accordingly. Default is ascending order.