0

hi,
my table has following fields
ForumPostsId(primary key),ForumPost,ParentPost
parentpost can have 0(which means its parentpost) or ForumPostsId(which means its a chlid post related to parentpost)

i need to generate a list which will the show parentpost and count of child post related to parent post

Any suggestion!!!!!!!!!

regards
rajan

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by simplypixie
0

Hi,

The query is quite simple. Play with Count() and Group by (with parentpostid) options in the SQL query. Give your best try and let us know.

Thank you,

hi,
my table has following fields
ForumPostsId(primary key),ForumPost,ParentPost
parentpost can have 0(which means its parentpost) or ForumPostsId(which means its a chlid post related to parentpost)

i need to generate a list which will the show parentpost and count of child post related to parent post

Any suggestion!!!!!!!!!

regards
rajan

0

This should do it (replace table_name with the name of your table):

SELECT count(ForumPostsId) as posts, ForumPostsId FROM table_name WHERE parentpost=0 GROUP BY ForumPostsId

Edited by simplypixie: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.