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
SELECT
IF(votenum >= 1, votenum, 0) AS votenum,
IF(votenum >= 1 AND votenum > 0, votetotal / votenum, 0) AS voteavg,
post.pagetext AS preview,
thread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, postusername, postuserid, thread.iconid AS threadiconid,
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,
thread.prefixid, thread.taglist, hiddencount, deletedcount
, deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason
, threadredirect.expires
, COUNT(zippy.userid)
FROM vb3_thread AS thread
LEFT JOIN vb3_deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND deletionlog.type = 'thread')
LEFT JOIN vb3_post AS post ON(post.postid = thread.firstpostid)
LEFT JOIN vb3_threadredirect AS threadredirect ON(thread.open = 10 AND thread.threadid = threadredirect.threadid)
LEFT JOIN vb3_zippyclick AS zippy ON (zippy.threadid = thread.threadid)
WHERE thread.threadid IN (0,46,45,44,43,41,40,39,38,37,31,30,26)
ORDER BY sticky DESC, lastpost DESC;
Gdzie leży problem ? Pozdrawiam.
EDIT: zapomniałem o pogrupowaniu. Czy
GROUP BY thread.threadid
będzie w pełni poprawnym grupowaniem ?
Ten post edytował seba123 25.08.2011, 19:02:17