我试图在游戏中获得玩家的灵魂数量以及所有其他统计数据。我正在尝试的查询是
SELECT t1.*, (SELECT COUNT(*) FROM t2 GROUP BY SoulLocationName WHERE SoulLocationName=t1.Name) AS SoulCount
FROM tblAvatar t1
JOIN tblAvatar t2 ON t1.Name = t2.SoulLocationName
我哪里错了?
答案 0 :(得分:1)
SELECT t1.*,
COUNT(t2.SoulLocationName) as SoulCount
FROM tblAvatar t1
JOIN tblAvatar t2
ON t1.Name = t2.SoulLocationName
答案 1 :(得分:1)
尝试此查询
SELECT t1.*, t2.SoulCount
FROM tblAvatar t1
JOIN(SELECT SoulLocationName,COUNT(*) as SoulCount FROM tblAvatar GROUP BY SoulLocationName) t2 ON t1.Name = t2.SoulLocationName