MySQL ORDER BY: ASC & DESC Sorting Guide

In MySQL, you can use the ORDER BY clause to sort query results in ascending or descending order. Here is an example statement:

  1. Sort by
SELECT column1, column2
FROM table_name
ORDER BY column1 ASC;

In the example above, ORDER BY column1 ASC indicates sorting in ascending order by the values in column1.

  1. sort by
SELECT column1, column2
FROM table_name
ORDER BY column1 DESC;

In the example above, ORDER BY column1 DESC indicates a descending order based on the values in column1.

It is important to note that if no sorting method is specified, the default is to sort in ascending order. You can choose between ascending or descending order based on your specific needs.

bannerAds