Sort MySQL results
Question:
How to sort MySQL results? Answer:
SELECT * FROM student ORDER BY birth_date DESC;
SELECT * FROM student ORDER BY rating DESC, name ASC;
Description:
The result rows of a SELECT
are displayed in no particular order. It is often easier to examine query output when the rows are sorted in some meaningful way. To sort a result, use an ORDER BY
clause.
Reference:
MySQL sorting reference
Share "How to sort MySQL results?"
Related snippets:
Tags:
sql, sorting, results, resultset, order, order by, desc, asc, mysql, mariadb Technical term:
Sort MySQL results