If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I'm not sure if I understood, but let's assume:
`table1` (topics) with columns `id` (int) and `dt` (datetime),
`table2` (replies) with columns `topicid` (int) and `a_dt` (datetime).
If you want to get the topics with their last activity (whether the topic creation or its last reply), you'll need something like this:

Code:

select t1.id, ifnull(max(t2.a_dt),t1.dt) as lastactivity
from table1 as t1
left join table2 as t2 on t1.id = t2.topicid
group by t1.id
order by lastactivity;