Creating a “forum” – showing last post or last commented post

You can add the standard taxonomy joins to the query:

global $wpdb;
$cat_id = 79; // Whatever.
$sql = "
    select wp_posts.*,
    coalesce(
        (
            select max(comment_date)
            from $wpdb->comments wpc
            where wpc.comment_post_id = wp_posts.id
        ),
        wp_posts.post_date
    ) as mcomment_date
    from $wpdb->posts wp_posts
    JOIN $wpdb->term_relationships AS tr ON wp_posts.ID = tr.object_id
    JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    where post_type="post"
    and post_status="publish"
    AND tt.term_id = $cat_id AND tt.taxonomy = 'category'
    order by mcomment_date desc
    limit 1
";
$ret = $wpdb->get_results($sql);