今天做了一个查询功能,点击查询按钮的时候,总是报错,后台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了