今天做了一个查询功能,点击查询按钮的时候,总是报错,后台DeBug一下。
这个功能是维修类别的列表页。

只有查询条件为空的时候,不会报错。
只有查询条件不为空,则报错。

com.shhx.hxems.mapper.RepairCategoryMapper.selectRepairCategoryList-Inline ### The error occurred while setting parameters ### SQL:
###Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE a.type = 'Y') tmp_count’ at line 12 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE a.type = ‘Y’) tmp_count’ at line 12
看下SQL :

这个oder by语句,后面肯定肯定不能带where条件,
所以把oder by 语句,放到where条件后面,就OK了

在开发一个维修类别列表的查询功能时,遇到一个问题:当查询条件不为空时,系统报错。错误信息提示SQL语法错误,特别是ORDER BY语句后的WHERE条件。解决方案是将ORDER BY语句移至WHERE条件之后,从而解决了问题。
17万+

被折叠的 条评论
为什么被折叠?



