我遇到有关“ Expr1000”的错误

时间:2018-11-04 07:39:41

标签: c# sql ms-access

最近,我建立了一个查询,该查询假设基于INNER JOIN为我提供以下所有列,以及与UserID相同的其他表,并对它们进行计数以使我最常见一次:

SELECT PhonesTBL.OperatingSystem 
   and PhonesTBL.Memory 
   and PhonesTBL.BatterySize 
   and PhonesTBL.CameraQuality 
   and PhonesTBL.Processor 
   and PhonesTBL.ScreenSize 
   and PhonesTBL.PhoneType 
FROM
    PhonesTBL 
INNER JOIN 
    HistoryTBL ON PhonesTBL.PhoneID = HistoryTBL.PhoneID 
WHERE 
    UserID = {0} 
GROUP BY OperatingSystem 
     and Memory 
     and BatterySize 
     and CameraQuality 
     and Processor 
     and ScreenSize 
     and PhoneType 
ORDER BY
    Count(*) DESC

此查询返回Expr1000。

1 个答案:

答案 0 :(得分:1)

SQL中的and关键字执行布尔和。因此,您的投影(select子句)和group by子句都生成单个值。

我希望您希望每种情况下用逗号分隔的表达式列表

Select PhonesTBL.OperatingSystem,
  PhonesTBL.Memory,
  PhonesTBL.BatterySize,
  PhonesTBL.CameraQuality, 
  PhonesTBL.Processor,
  PhonesTBL.ScreenSize, 
  PhonesTBL.PhoneType
[…]