MySQL ASC

Executing select query with order by clause returns the rows in the order of column name specified with the order by clause.

MySQL ASC

MySQL ASC

     

This example illustrates how to display data of the table in ascending order.

Executing select query with order by clause returns the rows in the order of column name specified with the order by clause. By default, the data is returned in ascending order. But you can explicitly mention the order of the result by ASC keyword. ASC determines that the results will be shown in ascending order. If you want the order in descending order then use DESC keyword.

In this example, select query displays data in ascending order of name.

 

 

 

 

Query
SELECT * FROM employee ORDER BY name ASC;
Output
+----+--------+----------------------+
| id | name   | designation          |
+----+--------+----------------------+
| 1  | Ajay   | programmer           |
| 3  | Kamal  | sr. graphic designer |
| 7  | Karan  | programmer           |
| 5  | Nitin  | content writer       |
| 8  | Rajesh | graphic designer     |
| 4  | Rajiv  | graphic designer     |
| 6  | Sachin | programmer           |
| 2  | Vinay  | programmer           |
+----+--------+----------------------+