Forums

This topic is locked

Help! I need to count

Posted 01 May 2003 14:53:09
1
has voted
01 May 2003 14:53:09 Andy Smith posted:
Hi all
Basically I cannot get my head round this problem! I need to count the amount of replies (counting number of records that display the same number) in a messageboard and for them to be displayed next to their subject in the repeat region.

I have the same forum_id number in the DB for each record that has a reply.

This won't work but hopefully you can get the jist of what I am trying to do:

SELECT subject, author, count(forum_id)
FROM messageboard
WHERE forumtype = 'MMColParam' GROUP BY forum_id
ORDER BY datestamp desc;

I need to disply the info like:

Topic: Test
Author: Tester
Replies: 4
Posted: 04/03/03

--------repeat region--------

Topic: Test2
Author: Tester2
Replies: 5
Posted: 08/01/02

--------repeat region--------

forum_id: is a numeric identifier for the thread
Author: The original poster
datestamp: The date!
subject: The post subject!
messageboard: The table


Any help to let me keep what little hair I have left would be great!

Thanks
Andy

Replies

Replied 01 May 2003 17:53:40
01 May 2003 17:53:40 Brent Colflesh replied:
This will be simple if you have a logical db structure:

User Info table w/appropriate fields.

Topic table w/appropriate fields, including relID to User info

Reply table w/appropriate fields, including relID to Topic -

Then you just count() the relID's from the Reply table related to your topic.

Regards,
Brent

Replied 01 May 2003 17:58:22
01 May 2003 17:58:22 Andy Smith replied:
Thanks Brent, will try

Replied 02 May 2003 17:56:11
02 May 2003 17:56:11 Stewart Harrison replied:
Try this

SELECT subject, author, count(forum_id)
FROM messageboard
WHERE forumtype = 'MMColParam' GROUP BY SUBJECT, AUTHOR
ORDER BY datestamp desc

Good luck.

Reply to this topic