I work on MySQL 5.7, I want to get the ID and TITLE of the last article for each category. For example I have the following table 'Article':
| ID | TITLE | DATE | FK_CATEGORY |
| 1 | title 1 | 2016-10-05 | 1 |
| 2 | title 2 | 2017-10-02 | 1 |
| 3 | title 3 | 2015-10-10 | 2 |
| 4 | title 4 | 2017-04-20 | 2 |
| 5 | title 5 | 2017-04-12 | 3 |
For this example I expect the result to be:
| 2 | title 2 | 2017-10-02 | 1 |
| 4 | title 4 | 2017-04-20 | 2 |
| 5 | title 5 | 2017-04-12 | 3 |
I have tryed this request but it does not work :
SELECT id, title, MAX(date), fk_category
FROM article
GROUP BY fk_category
ORDER BY date DESC
What query do I have to use ?
PS: I do not want to disable ONLY_FULL_GROUP_BY SQL mode