查询表达式中的语法错误(缺少运算符)'tblPlayerstatistics.MatchID = tblGameResults.MatchID COUNT tblPLayerStatistics.TwoPOinterMad。'

时间:2014-03-11 23:06:35

标签: mysql

我正在尝试通过选择在一场比赛中得分最高的球员来选择比赛的球员。我已经尝试计数添加2指针和3指针,这是找出高分的唯一方法。请Helpppp

SELECT tblPlayerStatistics.Player_ID_Number,
tblPlayerStatistics.TwoPointerMade,
tblPlayerStatistics.ThreePointerMade, 
MatchID
FROM tblPlayerStatistics
INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
COUNT tblPlayerStatistics.TwoPointerMade 
AND tblPlayerStatistics.ThreePointerMade
GROUP BY tblPlayerStatistics.Player_ID_Number;

2 个答案:

答案 0 :(得分:0)

你完全误解了COUNT的工作方式和MySQL的查询语法。如果您想累计点数,则需要使用SUM

您想要的查询是:

SELECT
    tblPlayerStatistics.Player_ID_Number,
    SUM(tblPlayerStatistics.TwoPointerMade + tblPlayerStatistics.ThreePointerMade) AS points, 
    MatchID
FROM
    tblPlayerStatistics
    INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
GROUP BY
    tblPlayerStatistics.Player_ID_Number,
    MatchID;

这应该让你开始走正确的道路

答案 1 :(得分:0)

您可以将表格tblPlayerStatistics重命名为thisismytableofthePlayerStatisticsever

试试:

   SELECT tblPlayerStatistics.Player_ID_Number,
   COUNT(tblPlayerStatistics.TwoPointerMade) as TwoPointerMade ,
   tblPlayerStatistics.ThreePointerMade, 
    MatchID
   FROM tblPlayerStatistics
   INNER JOIN tblGameResults ON tblPlayerStatistics.MatchID = tblGameResults.MatchID
   AND tblPlayerStatistics.ThreePointerMade
   GROUP BY tblPlayerStatistics.Player_ID_Number;