Hi I need help with sql query to get results in correct order
I've two tables:
Topic [ idtopic, idforum, title, description, views]
Post [ idpost, idtopic, iduser, message, dateadded ]
I need to get data from Topic table that is sorted by post.dateadded. It's for topics listing page on forum so it works like: somebody adds reply to topic and in my query fetching all topics that row should go on top. I hope you understand what i mean.
This is what i managed to write
Code:
SELECT t.title, p.dateadded
FROM Topic AS t
JOIN Post AS p ON p.idtopic = t.idtopic
WHERE t.idforum =1
ORDER BY p.dateadded DESC
That is almost what i want but I need it to sort by max(p.dateadded) -> the last post from topic, not by all posts like it's now (There should be less results).