SELECT *
FROM
threads as t1,
(SELECT *
FROM
posts as st1, threads as st2
WHERE st2.forum_id=1
AND st1.thread_id = st2.thread_id
ORDER BY st1.post_id DESC
) as t2
WHERE t1.forum_id=1
AND t2.forum_id = t1.forum_id
AND t2.thread_id = t1.thread_id
threads
--------------------------
thread_id | forum_id
--------------------------
1 | 1
2 | 1
3 | 2
4 | 1
5 | 2
posts
---------------------------------------------
post_id | thread_id | post_date
---------------------------------------------
1 | 1 | 2009-04-01 12:00:00
2 | 2 | 2009-04-01 13:00:00
3 | 2 | 2009-04-01 14:00:00
4 | 1 | 2009-04-01 15:00:00
5 | 3 | 2009-04-01 16:00:00
6 | 1 | 2009-04-01 17:00:00
7 | 4 | 2009-04-01 18:00:00
8 | 5 | 2009-04-01 19:00:00
9 | 5 | 2009-04-01 20:00:00
What I want is (for example, for forum 1)
------------------------------------------------------------
forum_id | post_id | thread_id | post_date
------------------------------------------------------------
1 | 6 | 1 | 2009-04-01 17:00:00
1 | 3 | 2 | 2009-04-01 14:00:00
1 | 7 | 4 | 2009-04-01 18:00:00
But I seem unable to find a request that does "just" that. Question can someone here help me? Thanks in advance (cookied are distributed accross teh intartube for every answer).