Now that we have looked at different techniques of retrieving the data, let us look at how the data can be represented in a more ordered way. When we execute a
SELECT statement, the data is retrieved in the order in which it exists in the database. This would be the order in which the data is stored; therefore, it is not a good idea to depend upon MariaDB's default sorting. MariaDB provides an explicit mechanism for sorting data; we can use the
ORDER BY clause with the
SELECT statement and sort the data as needed. To understand how sorting can be of help, let us begin by querying the
students table and only retrieving the
In the first example, we are going by MariaDB's default sort, and this would give us the data ...