Forums

ASP

This topic is locked

Count?

Posted 18 Jul 2001 11:53:57
1
has voted
18 Jul 2001 11:53:57 Joe Utichi posted:
Hi,

I am developing forums atm, and I'm trying to get some counting stuff going so that post/forum/message counter rise based on events on the forums.

Forum Detail lists all of the forums on the database in a table called Forums, and has a total post count. I want this to print the number of posts to the ForumID field of a second recordset, the message archive. Basically, each message is assigned a forum ID on add record and I need the Forum Detail page to count all the Relative forum IDs in the Message archive, add them togther and print the result. But I have no idea how. If I can figure this out, I can easily alppy the same thing to the Users post counts and the message replies counts. Any idea on how to aceieve this?

Replies

Replied 18 Jul 2001 13:36:05
18 Jul 2001 13:36:05 Joel Martinez replied:
you can accomplish what you're talking about in two ways (maybe more, but this is all I can think of now):

1. every time a post is added, update that number.

2. do an inner join... something like this:
<pre id=code><font face=courier size=2 id=code>SELECT forumname, count(messageID) as posts
FROM forumdetail
INNER JOIN messagearchive ON forumdetail.forumID = messagearchive.forumID
GROUP BY forumname</font id=code></pre id=code>

that should work, but if the forumname is in the forums table (which is how it should be if it was properly normalized) then you'd have to add a third inner join to the forums table to get the forumname...

hope that helps,

Joel Martinez

----------
Is this thing on?....

Reply to this topic