日期:2014-05-18 浏览次数:20599 次
SELECT A.PostsID, A.Title, B.CNT FROM Posts a INNER JOIN (SELECT PostsID, COUNT(*) AS cnt FROM Reply GROUP BY PostsID) B ON A.PostsID = B.PostsID
------解决方案--------------------
select a.*,b.num from Posts a, (select PostsID,count(1) as num from Reply group by PostsIDZ)b where a.PostsID=b.PostsID