nothing like this?
AND t.topic_id = p.topic_id
AND f.forum_id = t.forum_id