mybatis foreach in查询语句 关于逗号 空值处理问题

原查询代码:


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 ,多个逗号连续的也是一样的

        
        
            AND m1.code in 
             
                    #{item} 
             
        

你可能感兴趣的:(mybatis foreach in查询语句 关于逗号 空值处理问题)