'Where to put ORDER BY in this MySQL statement in Python

Where do I put ORDER BY weight_record.date in this statement to fetchall() into an array sorted by earliest date to latest?

mycursor.execute(
"SELECT weight_record.date AS wr_date, 
weight_record.weight AS wr_weight, 
calorie_record.calories AS cr_calories 
FROM weight_record 
JOIN calorie_record ON weight_record.date = calorie_record.date 
WHERE weight_record.username = %s 
AND calorie_record.username = %s", (user, user))

Thank you.



Solution 1:[1]

From the documentation, ORDER BY should come after the WHERE clause.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ndc85430