SELECT SampleSheet.Id,SampleSheet.Sample_Complete,SampleSheet.SampleName,"
+ "count(Job.sampleId) AS NumberOfSamples FROM (SampleSheet "
+ "LEFT JOIN Job ON SampleSheet.Id = Job.sampleId) "
+ "WHERE SampleSheet.Sample_Complete=?"
+ "GROUP BY SampleSheet.Id
请问任何人请告诉我这个查询中有什么不对。我收到语法错误。
如果我不使用Where条件,它的工作正常。但我需要获取样本完成的行。
SELECT SampleSheet.Id,SampleSheet.Sample_Complete,SampleSheet.SampleName,count(Job.sampleId) AS NumberOfSamples FROM (SampleSheet LEFT JOIN Job ON SampleSheet.Id = Job.sampleId) GROUP BY SampleSheet.Id
答案 0 :(得分:3)
有几点建议。在WHERE
子句
+ "WHERE SampleSheet.Sample_Complete=?"
+ "GROUP BY SampleSheet.Id
代替
+ "WHERE SampleSheet.Sample_Complete=? "
+ "GROUP BY SampleSheet.Id
您也可以在(
之后删除FROM
,并明显)
。这不是必需的。
FROM (SampleSheet "
+ "LEFT JOIN Job ON SampleSheet.Id = Job.sampleId) "