Let's assume I have a database with two tables: categories
and articles
. Every article belongs to a category.
Now, let's assume I want to fetch the latest article of each category that fits a specific criteria (read: the article does). If it weren't for that extra criteria, I could just add a column called last_article_id
or something similar to the categories
table - even though that wouldn't be properly normalized.
How can I do this though? I assume there's something using GROUP BY
and HAVING
?