I have the article
table, each having a related category (or NULL if not categorized - these articles don't interest me in this case).
I want to get 8 newest articles each from one category in a way that there is always only one article for one category (i.e. never 2 articles from the same category).
This query almost work:
SELECT article.id, article.title, category_container.title FROM `article`
JOIN `category_container` ON category_container.id = article.category_id
WHERE `category_id` IS NOT NULL GROUP BY `category_id` ORDER BY article.created_at DESC LIMIT 8
The problem is, ORDER doesn't work. I want newest, it returns me the earliest ones (with the smallest id, while it should be the opposite).
So, how to apply ORDER to GROUP BY?