The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Lets hope someone can help me!
Basically, i am trying to select from the database, the top 10 most posts, with the most replies, which expire after 7 days regardless, ie, only posts before 7 days ago are shown, easy you might say? well i dont actually want it 7 days from the start of the THREAD, i want it 7 days from the LAST reply. However, for the life of me, i cant think of a way to do it. The code i tried-> Code:
$replycountquery = "SELECT thread.*, post.*"; $replycountquery .= " FROM thread,post"; $replycountquery .= " WHERE thread.threadid=post.threadid"; $replycountquery .= " AND threadid=$newsforums"; $replycountquery .= " AND post.dateline > " . $replycountexpire; $replycountquery .= " GROUP BY thread.threadid"; $replycountquery .= " ORDER BY threadid.replycount DESC"; $replycountquery .= " LIMIT $newsitems"; code ive also tried in testing, this works, however has no date stuff, as no post table is introduced. Code:
$replycountquery = "SELECT thread.*"; $replycountquery .= " FROM thread"; $replycountquery .= " WHERE forumid = $newsforums"; $replycountquery .= " ORDER BY thread.replycount DESC"; $replycountquery .= " LIMIT $newsitems"; I just wish i had more SQL books!
|
|
#2
|
||||
|
||||
|
Try:
Code:
SELECT thread.*, post.* FROM thread
LEFT JOIN post ON (threadid)
WHERE thread.threadid=post.threadid
AND forumid=$newsforums
AND post.dateline > $replycountexpire
GROUP BY thread.threadid";
ORDER BY threadid.replycount DESC LIMIT 0,$newsitems";
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|