Can’t figure this out; I have a query with GROUP BY, but the ORDER BY is not working (is ordering accordingly to the GROUP BY field).
This is the query:
SELECT item.*,
customer.title AS customertitle
FROM gallery_items AS item
LEFT JOIN gallery_customers AS customer ON (customer.id = item.customerid)
WHERE item.published=1
GROUP BY item.id
ORDER BY item.created DESC
I have little knowledge of mysql; what’s going on here and how can I sort on the created-field?
Thanks!
Remove the GROUP BY and it should work.
GROUP BY is useful when you want to use aggregate functions such as MIN or MAX to get a single value for each group, however it seems that you aren’t doing that here.