kwilliams
08-16-2004, 09:55 AM
Thanks for any help in advance,
I have a "Bulletin Board" display page that is supposed to display all of the "Original Posts" from dbo.BulletinBoard. It's also supposed to display the Count for "Original Posts" and "Reply Posts" (from dbo.Replies) added together.
All of this data is within one Select statment, and is looped together for display. The problem that I'm having is that only the "Original Posts" with "Reply Posts" are being displayed. Here's the data:
SELECT STATEMENT:
SELECT BB.Topic, BB.DateTime, ME.FName, ME.LName, BB.Cat_ID, ME.Email, BB.Post_ID, BB.Member_ID, ME.Member_ID AS Expr1, RE.Post_ID AS Expr2, (SELECT COUNT(*) FROM dbo.BulletinBoard AS BB WHERE BB.Post_ID = RE.Post_ID)AS OriginalPosts, (SELECT COUNT(*) FROM dbo.Replies AS RE WHERE BB.Post_ID = RE.Post_ID) AS Replies
FROM dbo.BulletinBoard BB INNER JOIN dbo.Members ME ON BB.Member_ID = ME.Member_ID INNER JOIN dbo.Replies RE ON BB.Post_ID = RE.Post_ID
WHERE BB.Cat_ID = MMColParam
ORDER BY BB.DateTime DESC
VARIABLES:
MMColParam BB.Cat_ID Session("Cat_ID")
WANTED RESULTS:
To pull up original posts whether they have a reply post or not.
ACTUAL RESULTS:
Pulling original posts ONLY if they have a reply post.
NOTES:
The part that says:
(SELECT COUNT(*) FROM dbo.BulletinBoard AS BB WHERE BB.Post_ID = RE.Post_ID) AS OriginalPosts, (SELECT COUNT(*) FROM dbo.Replies AS RE WHERE BB.Post_ID = RE.Post_ID) AS Replies
...is a count method within the select statement that allows for me to pull the count for original & reply posts for display on the looped data within the page:
[CODE}<% while ((Repeat1__numRows-- != 0) && (!rsBulletinBoard.EOF)) { %>
<tr valign="top" bgcolor="#FFFFCC">
<td><a href="topic.asp?Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>&Post_ID=<%=(rsBulletinBoard.Fields.Item("Post_ID").Value)%>"><%=(rsBulletinBoard.Fields.Item("Topic").Value)%></a></td>
<td><div align="center" class="style1">
<%
var OriginalPosts = (rsBulletinBoard.Fields.Item("OriginalPosts").Value);
var Replies = (rsBulletinBoard.Fields.Item("Replies").Value);
Response.Write(OriginalPosts + Replies);
%>
</div></td>
<td><div align="center" class="style1"><%=(rsBulletinBoard.Fields.Item("DateTime").Value)%></div></td>
<td><div align="center" class="style1"><a class="small" href="mailto:<%=(rsBulletinBoard.Fields.Item("Email").Value)%>?Subject=Bulletin Board"><%=(rsBulletinBoard.Fields.Item("FName").Value)%> <%=(rsBulletinBoard.Fields.Item("LName").Value)%></a></div></td>
</tr>
<tr valign="top" bgcolor="#FFFFCC">
<td colspan="4" class="small"><div align="right" class="small"><a class="small" href="newpost.asp?Type_ID=New&Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>">New Post</a> | <a class="small" href="newpost.asp?Type_ID=Reply&Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>&Post_ID=<%=(rsBulletinBoard.Fields.Item("Post_ID").Value)%>">Reply to Post</a></div></td>
</tr>
<tr valign="top" bgcolor="#330066">
<td colspan="4"><img src="Images/spacer.gif" width="1" height="1"></td>
</tr>
<%
Repeat1__index++;
rsBulletinBoard.MoveNext();
}
%>[/CODE]
Any suggestions on what I'm doing wrong would be very much appreciated. Thanks.
I have a "Bulletin Board" display page that is supposed to display all of the "Original Posts" from dbo.BulletinBoard. It's also supposed to display the Count for "Original Posts" and "Reply Posts" (from dbo.Replies) added together.
All of this data is within one Select statment, and is looped together for display. The problem that I'm having is that only the "Original Posts" with "Reply Posts" are being displayed. Here's the data:
SELECT STATEMENT:
SELECT BB.Topic, BB.DateTime, ME.FName, ME.LName, BB.Cat_ID, ME.Email, BB.Post_ID, BB.Member_ID, ME.Member_ID AS Expr1, RE.Post_ID AS Expr2, (SELECT COUNT(*) FROM dbo.BulletinBoard AS BB WHERE BB.Post_ID = RE.Post_ID)AS OriginalPosts, (SELECT COUNT(*) FROM dbo.Replies AS RE WHERE BB.Post_ID = RE.Post_ID) AS Replies
FROM dbo.BulletinBoard BB INNER JOIN dbo.Members ME ON BB.Member_ID = ME.Member_ID INNER JOIN dbo.Replies RE ON BB.Post_ID = RE.Post_ID
WHERE BB.Cat_ID = MMColParam
ORDER BY BB.DateTime DESC
VARIABLES:
MMColParam BB.Cat_ID Session("Cat_ID")
WANTED RESULTS:
To pull up original posts whether they have a reply post or not.
ACTUAL RESULTS:
Pulling original posts ONLY if they have a reply post.
NOTES:
The part that says:
(SELECT COUNT(*) FROM dbo.BulletinBoard AS BB WHERE BB.Post_ID = RE.Post_ID) AS OriginalPosts, (SELECT COUNT(*) FROM dbo.Replies AS RE WHERE BB.Post_ID = RE.Post_ID) AS Replies
...is a count method within the select statement that allows for me to pull the count for original & reply posts for display on the looped data within the page:
[CODE}<% while ((Repeat1__numRows-- != 0) && (!rsBulletinBoard.EOF)) { %>
<tr valign="top" bgcolor="#FFFFCC">
<td><a href="topic.asp?Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>&Post_ID=<%=(rsBulletinBoard.Fields.Item("Post_ID").Value)%>"><%=(rsBulletinBoard.Fields.Item("Topic").Value)%></a></td>
<td><div align="center" class="style1">
<%
var OriginalPosts = (rsBulletinBoard.Fields.Item("OriginalPosts").Value);
var Replies = (rsBulletinBoard.Fields.Item("Replies").Value);
Response.Write(OriginalPosts + Replies);
%>
</div></td>
<td><div align="center" class="style1"><%=(rsBulletinBoard.Fields.Item("DateTime").Value)%></div></td>
<td><div align="center" class="style1"><a class="small" href="mailto:<%=(rsBulletinBoard.Fields.Item("Email").Value)%>?Subject=Bulletin Board"><%=(rsBulletinBoard.Fields.Item("FName").Value)%> <%=(rsBulletinBoard.Fields.Item("LName").Value)%></a></div></td>
</tr>
<tr valign="top" bgcolor="#FFFFCC">
<td colspan="4" class="small"><div align="right" class="small"><a class="small" href="newpost.asp?Type_ID=New&Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>">New Post</a> | <a class="small" href="newpost.asp?Type_ID=Reply&Cat_ID=<%=(rsBulletinBoard.Fields.Item("Cat_ID").Value)%>&Post_ID=<%=(rsBulletinBoard.Fields.Item("Post_ID").Value)%>">Reply to Post</a></div></td>
</tr>
<tr valign="top" bgcolor="#330066">
<td colspan="4"><img src="Images/spacer.gif" width="1" height="1"></td>
</tr>
<%
Repeat1__index++;
rsBulletinBoard.MoveNext();
}
%>[/CODE]
Any suggestions on what I'm doing wrong would be very much appreciated. Thanks.