Cześć! Mam następujący problem. Po dodaniu do zapytania SQL instrukcji COUNT serwer zwraca zawsze tylko jeden wynik. Bez wybierania zliczania rekordów wszystko jest ok. Oto moje zapytanie

  1. SELECT
  2. IF(votenum >= 1, votenum, 0) AS votenum,
  3. IF(votenum >= 1 AND votenum > 0, votetotal / votenum, 0) AS voteavg,
  4. post.pagetext AS preview,
  5. thread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, postusername, postuserid, thread.iconid AS threadiconid,
  6. thread.dateline, notes, thread.visible, sticky, votetotal, thread.attach, thread.lastpost, thread.lastposter, thread.lastpostid, thread.replycount, IF(thread.views<=thread.replycount, thread.replycount+1, thread.views) AS views,
  7. thread.prefixid, thread.taglist, hiddencount, deletedcount
  8.  
  9. , deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason
  10.  
  11. , threadredirect.expires
  12. , COUNT(zippy.userid)
  13. FROM vb3_thread AS thread
  14. LEFT JOIN vb3_deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND deletionlog.type = 'thread')
  15.  
  16.  
  17. LEFT JOIN vb3_post AS post ON(post.postid = thread.firstpostid)
  18.  
  19. LEFT JOIN vb3_threadredirect AS threadredirect ON(thread.open = 10 AND thread.threadid = threadredirect.threadid)
  20. LEFT JOIN vb3_zippyclick AS zippy ON (zippy.threadid = thread.threadid)
  21. WHERE thread.threadid IN (0,46,45,44,43,41,40,39,38,37,31,30,26)
  22. ORDER BY sticky DESC, lastpost DESC;


Gdzie leży problem ? Pozdrawiam.

EDIT: zapomniałem o pogrupowaniu. Czy
  1. GROUP BY thread.threadid
będzie w pełni poprawnym grupowaniem ?