从评论表中计算发表评论到每个有联接的帖子。 [英] Count Post Comment from Comment table to each post with joins.
本文介绍了从评论表中计算发表评论到每个有联接的帖子。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表Post和另一个P_comment。
表中Post = 10 Records(Post)
in p_Comment = 20 Rcords (每篇文章的2条评论)
我想用其计数评论(多少)获取帖子。
所以任何专家都可以解决我的问题。
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.
推荐答案
SELECT p.PostID, Count(c.*)
FROM Post p
LEFT JOIN P_comment c ON p.PostID = c.PostID
GROUP BY p.PostID
这篇关于从评论表中计算发表评论到每个有联接的帖子。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文