MYSQL
June 3, 2026 1 min read

Data Sorting in MYSQL: Mastering ORDER BY for Ascending and Descending Record Sorting

HS
HEMANT SINGH
Technical Writer & Educator

ORDER BY keyword is used to sort records in the form of ascending or descending.

For the ORDER BY command, we will use this given table as an example.

Table: users

idusernameagecountry
1Aman20India
2John20USA
3Ahmad20Pakistan

ORDER BY (ASC)

This command will fetch all the records from a table by sorting specified field values in ascending order.

SELECT * FROM users ORDER BY country ASC;

Table: users

idusernameagecountry
1Aman20India
3Ahmad20Pakistan
2John20USA

 

ORDER BY (DESC)

This command will fetch all the records from a table by sorting specified field values in descending order.

SELECT * FROM users ORDER BY country DESC;

Table: users

idusernameagecountry
2John20USA
3Ahmad20Pakistan
1Aman20India