gpt4 book ai didi

mysql - 选择具有连接语法错误的查询

转载 作者:太空宇宙 更新时间:2023-11-03 11:35:19 25 4
gpt4 key购买 nike

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

最佳答案

有几个建议。这似乎是 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) "

关于mysql - 选择具有连接语法错误的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46492652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com