Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mcsleazycrisps
Starting Member
1 Post |
Posted - 2004-08-17 : 10:34:54
|
| I'm currently developing a forum system and trying to get the page to display the number of posts under a topic, and if there's any file "attachments" to the post the data is stored like this:[TABLE NAME: site_forum_thread]forum_threadid (id)motherid ( the parent topic - 0 if it's a "top-level" post)forumid (what forum it belongs to)titletxtfilename ( filename if there's a file attached, otherwise NULL)pubdateauthor (int field referring to the id in a user's table)To display a list of all the topics in the forum it pulls all the records with a motherid of 0 and it's author (using a join).select site_forum_thread.*, site_reg.username, site_reg.regid from site_forum_thread LEFT JOIN site_reg on site_forum_thread.author = site_reg.regid where forumid = @forumid AND motherid = 0What i need it to do is to count the number of children under the motherid and the number of filenames. I'm using stored procedures... any ideas on how to do this? I've tried using a nested select but it keeps returning 0 - unless i'm doing something wrong.Thanks! |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-17 : 11:46:19
|
| corey what is this, the second time we did that?? next time i'll post yours and you do the one on sqlteam, just for the fun of it :)))Go with the flow & have fun! Else fight the flow :) |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-08-17 : 11:56:10
|
| kCorey |
 |
|
|
|
|
|