Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

ORDER BY Clause
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible