Click here to Skip to main content
15,029,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two table Post and Another P_comment.

In table Post = 10 Records(Post)
In p_Comment = 20 Rcords (2 comments on Each post)

And I want To Fetch Post With Its Counted Comments(How much).

So any Expert Can Solve my problem.
Posted

1 solution

SQL
SELECT p.PostID, Count(c.*)
FROM Post p
LEFT JOIN P_comment c ON p.PostID = c.PostID
GROUP BY p.PostID
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900