MariaDB ORDER BY Clause is used to sort the records in your result set in ascending or descending order.
Note: You can sort the result without using ASC/DESC attribute. By default, the result will be stored in ascending order.
Syntax:
SELECT expressions
FROM tables
[WHERE conditions]
ORDER BY expression [ ASC | DESC ];
ORDER BY Clause without using ASC/DESC attributes:
"Employees" table, having the following data:
Id Name address
1 Lucky Australia
2 Mayank Ghaziabad
3 Rahul Noida
4 Lily LA
SELECT * FROM Employees
WHERE name LIKE '%L%'
ORDER BY id;
Output:
Id Name address
4 Lily LA
3 Rahul Noida
2 Mayank Ghaziabad
1 Lucky Australia