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

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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.