Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.740
diff -u -p -r1.740 comment.module
--- modules/comment/comment.module	10 Jul 2009 05:50:08 -0000	1.740
+++ modules/comment/comment.module	13 Jul 2009 17:26:27 -0000
@@ -400,11 +400,11 @@ function comment_new_page_count($num_com
   else {
     // Threaded comments.
     // Find the first thread with a new comment.
-    $result = db_query_range('(SELECT thread
+    $result = db_query_range('SELECT thread FROM (SELECT thread
       FROM {comment}
       WHERE nid = :nid
         AND status = 0
-      ORDER BY timestamp DESC)
+      ORDER BY timestamp DESC) AS thread
       ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1))', array(':nid' => $node->nid), 0, $new_replies)->fetchField();
     $thread = substr($result, 0, -1);
     $count = db_query('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
