diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index <HASH>..<HASH> 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -3317,7 +3317,8 @@ function forum_tp_count_forum_unread_posts($userid, $forumid, $groupid=false) {
     }
 
     $sql = 'SELECT COUNT(p.id) '.
-           'FROM '.$CFG->prefix.'forum_posts p JOIN '.$CFG->prefix.'forum_discussions d ON p.discussion = d.id '.
+           'FROM '.$CFG->prefix.'forum_posts p '.
+           'LEFT JOIN '.$CFG->prefix.'forum_discussions d ON p.discussion = d.id '.
            'LEFT JOIN '.$CFG->prefix.'forum_read r ON r.postid = p.id AND r.userid = '.$userid.' '.
            'WHERE d.forum = '.$forumid.$groupsel.
                 ' AND p.modified >= '.$cutoffdate.' AND r.id is NULL';
Corrected a typo that was throwing errors.