我在以下SQL语句中遇到运算符错误:
SELECT Sample.Number, Sample.SampleDate, BOD.BOD_Concentration_IN, BOD.BOD_Concentration_OUT, TSS.TSS_Influent, TSS.TSS_Effluent
FROM SampleInformation as Sample
INNER JOIN BOD_Data as BOD ON Sample.Number = BOD.Number
INNER JOIN TSS_Data as TSS ON Sample.Number = TSS.Number
WHERE (DATEPART('m',Sample.SampleDate) = DATEPART('m',#1/13/2016 12:01:00 PM#))
AND (DATEPART('yyyy',Sample.SampleDate) = DATEPART('yyyy',#1/13/2016 12:01:00 PM#)) ORDER BY Sample.SampleDate
我淘汰了" WHERE"子句仍然有错误,所以它必须在连接中。
谁能看到我在这里失踪的东西?谢谢!
答案 0 :(得分:0)
我终于发现你在'FROM'条款周围缺少()...尝试以下方法:
顺便说一句,“数字”不需要括在括号内(尽管它是一个保留字)
SELECT Sample.Number, Sample.SampleDate, BOD.BOD_Concentration_IN, BOD.BOD_Concentration_OUT, TSS.TSS_Influent, TSS.TSS_Effluent
FROM (SampleInformation AS Sample
INNER JOIN BOD_Data AS BOD ON Sample.Number = BOD.Number)
INNER JOIN TSS_Data AS TSS ON Sample.Number = TSS.Number
WHERE (DATEPART('m',Sample.SampleDate) = DATEPART('m',#1/13/2016 12:01:00 PM#))
AND (DATEPART('yyyy',Sample.SampleDate) = DATEPART('yyyy',#1/13/2016 12:01:00 PM#)) ORDER BY Sample.SampleDate