Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
ORDER BY Clause
On this page

ORDER BY

In MySQL, the ORDER BY clause is used to sort the result set of a query based on one or more columns. It is typically used with the SELECT statement to arrange the rows in a specific order.

Syntax

SELECT column1, column2 FROM table_name WHERE condition ORDER BY column1 [ASC | DESC], column2 [ASC | DESC];

Here's a brief explanation of the components:

  • ASC: Ascending order (default). Rows are sorted from the smallest value to the largest value.
  • DESC: Descending order. Rows are sorted from the largest value to the smallest value.

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page