Python MariaDB – Order By Clause using PyMySQL
A MySQL client library is employed when we have to use MySQL with other programming languages. The work of PyMySQL is to provide access to MySQL Driver to the required language. Thus, it generates a connection between the programming language and the MySQL Server.
The OrderBy is used to arrange the result set in either ascending or descending order. By default, it is always in ascending order unless “DESC” is mentioned, which arranges it in descending order. “ASC” can also be used to explicitly arrange it in ascending order. But, it is generally not done this way since default already does that.
SELECT column_list FROM table_name ORDER BY column_name ASC|DESC;
The following programs will help you understand this better.
Table in use :
Example 1: Program to arrange the data in ascending order by PRODUCT_TYPE
Example 2: Arranging the table in descending order by price
Example 3: Arranging the table in ascending order by price