Mornin'
I've got a table that stores news articles - each belongs to a category and has a submission date. I want to find the latest article for each category. If I run the following query (linkTitle is the article name - pageTitle is the category - pageGroup denotes they are NEWS articles) it gives me the last entries in the table. Presumably it's because the query just pulls each result in sequence and the GROUP BY clause just squashes them together with the last in at the top. I can't put the 'order by pageAge' clause before 'Group by' so I can't get the last (by date) to show in the result correctly.
What's the solution?
select linkTitle,ownerID,pageTitle from page_content LEFT JOIN page_title ON ownerID=pageID WHERE pageGroup = 3 GROUP BY pageTitle order by pageAge;
+------------------+---------+-------------+
| linkTitle | ownerID | pageTitle |
+------------------+---------+-------------+
| recruitment news | 0005 | recruitment |
| asd | 0016 | industry |
| New react site | 0001 | react |
| tech news | 0018 | technology |
+------------------+---------+-------------+
(These are just the last entries for each category in the table - regardless of pageAge)