原查询代码:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;
。。。。。。。。
Caused by: 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 ‘group by mach_id,code
) d1,
(
select mach_id,sum(price) as total_price, m1’ at line 27
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
最终处理:
加上 machList的长度判断即可
如果machIdList 以逗号输入的话
machGoodsDaySale.getMachIdList().split(“,”)
得到的数组长度将是为0 ,多个逗号连续的也是一样的
<!-- 多个专柜 -->
<if test="machList != null and machList != '' and machList.length > 0">
AND m1.code in
<foreach collection="machList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>