我有下面的查询,它创建了两个表之间的连接,它正在工作fint但我想也显示在“T”中没有出现在D中的所有数据。这只显示来自的Twwet ID在两者中,我是否还可以显示在D中不是Apper但在T
中执行的OnesSELECT
t.ClientId,
t.PageName,
t.Country,
t.CreatedAt,
t.TweetId,
t.TweetMessage,
t.Replied,
t.RetweetCount,
t.FavoritedCount,
t.en_Media_type,
Sum(d.FollowersCount) As TotalFollowers
FROM dbo.[Tweets(HT)] AS t
INNER JOIN dbo.RetweetersData AS d ON d.TweetID = t.TweetId
WHERE t.ClientId = 54
GROUP BY t.ClientId,
t.PageName,
t.Country,
t.CreatedAt,
t.TweetId,
t.TweetMessage,
t.Replied,
t.RetweetCount,
t.FavoritedCount,
t.en_Media_type
答案 0 :(得分:4)
更改
INNER JOIN dbo.RetweetersData ...
到
LEFT JOIN dbo.RetweetersData ...
答案 1 :(得分:1)
我认为您需要使用Left join而不是Inner join 尝试以下
SELECT
t.ClientId,
t.PageName,
t.Country,
t.CreatedAt,
t.TweetId,
t.TweetMessage,
t.Replied,
t.RetweetCount,
t.FavoritedCount,
t.en_Media_type,
Sum(d.FollowersCount) As TotalFollowers
FROM dbo.[Tweets(HT)] AS t
Left JOIN dbo.RetweetersData AS d ON d.TweetID = t.TweetId
WHERE t.ClientId = 54
GROUP BY t.ClientId,
t.PageName,
t.Country,
t.CreatedAt,
t.TweetId,
t.TweetMessage,
t.Replied,
t.RetweetCount,
t.FavoritedCount,
t.en_Media_type