Python MySQL

MySQL Order By

Sorting results

MySQL Order By

You can sort the result in ascending or descending order using the ORDER BY statement.

Sort Results

mycursor.execute("SELECT * FROM customers ORDER BY name")
myresult = mycursor.fetchall()
for x in myresult:
    print(x)