Computer >> Computer tutorials >  >> Programming >> MySQL

What is the default sort order in MySQL tables?


The default sort order in MySQL tables is ascending. Whenever we use ORDER BY clause to sort out the rows of a table, MySQL gives output in ascending order, with the smallest value first. Consider the following example from a table named ‘student’ −

mysql> Select * from student order by name;
+--------+--------+--------+
| Name   | RollNo | Grade  |
+--------+--------+--------+
| Aarav  | 150    | M.SC   |
| Aryan  | 165    | M.tech |
| Gaurav | 100    | B.tech |
+--------+--------+--------+
3 rows in set (0.00 sec)

We can see the query above gives the output, ordered by name, in ascending order, start with smallest value ‘Name’ column.