PDA

View Full Version : سوال: select از 3 جدول



fakhravari
چهارشنبه 11 آبان 1390, 01:28 صبح
با سلام
در select از 2 جدول مشکلی نیست . ولی select 3 جدول شرط برقرار میشه اما یه مشکلی داره توی جمع زدن
اگه دوستان کمکی کنند
SELECT TOP 6 TBLNews.NewsID, TBLNews.Title, TBLNews.Abstract, TBLNews.Contents, TBLNews.AddDate, TBLNews.img, Sum(RatingPost.Rating) AS SumOfRating, Count(RatingPost.PostID) AS CountOfPostID, Count(Comments.ID) AS CountOfID
FROM (TBLNews Left Outer Join RatingPost ON TBLNews.NewsID = RatingPost.PostID ) Left Outer Join Comments ON TBLNews.NewsID = Comments.PostID
GROUP BY TBLNews.NewsID, TBLNews.Title, TBLNews.Abstract, TBLNews.Contents, TBLNews.AddDate, TBLNews.img
ORDER BY NewsID DESC;