So my problem is I'm trying to use ORDER BY on columns from multiple tables, the multiple tables are always the same one.
My SQL statement:
SELECT
n0.val AS n312,
n1.val AS n309,
c.food_name,
f.name,
FROM contents n0, contents n1, contents c
LEFT JOIN foods f ON f.id = c.food_id
WHERE n0.url = c.url AND n0.orig_source_id = 312 AND n1.url = c.url AND n1.orig_source_id = 309
GROUP BY c.food_name
ORDER BY n312 DESC, n309 DESC
LIMIT 30
The problem is here only the n312 is ordered and not the n309, they both should be ordered right? I assume this is a problem with the multiple tables in the query but not sure how I can fix this. The values are both decimals.
Any help will be appreciated, thanks.
