سفارش بر اساس DESC(ORDER BY DESC)
از کلمه کلیدی DESC برای مرتب کردن نتایج به ترتیب نزولی استفاده کنید.
مثال
Sort the result reverse alphabetically by name:
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="youruse
ame",
passwd="yourpassword",
database="mydatabase"
)
mycursor = mydb.cursor()
sql = "SELECT * FROM customers ORDER BY
name DESC"
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
print(x)