Now I got this error:
1054
Unknown column 'r.count' in 'order clause' SQL=SELECT a.id FROM jos_phocagallery AS a LEFT JOIN jos_phocagallery_categories AS cc ON cc.id = a.catid WHERE a.catid= 2 AND a.published = 1 AND a.approved = 1 ORDER BY r.count ASC, a.id ASC
Column count is not missing (it's in jos_phocagallery_categories).
IMHO the issue is in the query, in the part ORDER BY r.count... r is alias for which table?
I guess that the correct query is
SELECT a.id FROM jos_phocagallery AS a LEFT JOIN jos_phocagallery_categories AS cc ON cc.id = a.catid WHERE a.catid= 2 AND a.published = 1 AND a.approved = 1 ORDER BY cc.count ASC, a.id ASC

