1. Sort order by, the ORDER BY
clause allows to sort the result set on a single column or multiple columns. Sorts the result set of different columns in ascending or descending order.
2. Syntax:
SELECT column1, column2,... FROM tbl ORDER BY column1 [ASC|DESC], column2 [ASC|DESC],...
ASC
For ascending order, DESC
for descending order. By default, if you do not specify ASC
or explicitly DESC
, the ORDER BY
clause sorts the result set in ascending order.
3. In addition, the ORDER BY
clause allows to FIELD()
define your own custom sort order for the values in the column using functions. Functions can be used FIELD()
to map these values to a list of values, and to sort by numbers