Kaitlyn2004
11-13-2007, 06:03 PM
This is the threadcount query in forumdisplay:
SELECT COUNT( * ) AS threads, SUM( IF( thread.lastpost >1194966616
AND OPEN <>10, 1, 0 ) ) AS newthread
FROM vb3thread AS thread
WHERE forumid =11
AND sticky =0
AND visible
IN ( 0, 1, 2 )
I have another table, vb3tags ... has tag, and threadid columns. If I want to search multiple tags (AND) I might do something like this (off top of head):
SELECT COUNT( * ) AS threads, SUM( IF( thread.lastpost >1194966616
AND OPEN <>10, 1, 0 ) ) AS newthread
FROM vb3thread AS thread, vb3tags AS tags
WHERE forumid =11
AND sticky =0
AND visible
IN ( 0, 1, 2 )
AND tags.threadid = thread.threadid
AND tags.Tag IN ('tag1', 'tag2')
GROUP BY thread.threadid
HAVING COUNT(thread.threadid) = 2
Of course, that doesn't work. Can anyone help me along with this? My method works for everything EXCEPT the counting of threads..
ALL help greatly appreciated
SELECT COUNT( * ) AS threads, SUM( IF( thread.lastpost >1194966616
AND OPEN <>10, 1, 0 ) ) AS newthread
FROM vb3thread AS thread
WHERE forumid =11
AND sticky =0
AND visible
IN ( 0, 1, 2 )
I have another table, vb3tags ... has tag, and threadid columns. If I want to search multiple tags (AND) I might do something like this (off top of head):
SELECT COUNT( * ) AS threads, SUM( IF( thread.lastpost >1194966616
AND OPEN <>10, 1, 0 ) ) AS newthread
FROM vb3thread AS thread, vb3tags AS tags
WHERE forumid =11
AND sticky =0
AND visible
IN ( 0, 1, 2 )
AND tags.threadid = thread.threadid
AND tags.Tag IN ('tag1', 'tag2')
GROUP BY thread.threadid
HAVING COUNT(thread.threadid) = 2
Of course, that doesn't work. Can anyone help me along with this? My method works for everything EXCEPT the counting of threads..
ALL help greatly appreciated